Opened 12 years ago

Closed 11 years ago

#4827 closed (fixed)

str.upper() failed in _get_installed_models when syncdb

Reported by: timchen119@… Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: Keywords: unicode oracle str
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



I'm using django svn-5640

#python syncdb
Traceback (most recent call last):
  File "", line 11, in ?
  File "/usr/lib/python2.4/site-packages/django/core/", line 1742, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/usr/lib/python2.4/site-packages/django/core/", line 1639, in execute_from_command_line
    action_mapping[action](int(options.verbosity), options.interactive)
  File "/usr/lib/python2.4/site-packages/django/core/", line 549, in syncdb
    seen_models = _get_installed_models(table_list)
  File "/usr/lib/python2.4/site-packages/django/core/", line 71, in _get_installed_models
    return set([m for m in all_models if converter(m._meta.db_table) in map(converter, table_list)])
TypeError: descriptor 'upper' requires a 'str' object but received a 'unicode'

Since some backend (eg:oracle xe) use case insensitive table names, 
django will run str.upper() to make table names unique.
however str.upper() expect for a str type,
and now django trunk version give a unicode type back,
that would cause a problem.


Change str.upper() in _get_installed_models at to string.upper() would avoid this problem.

--- /usr/lib/python2.4/site-packages/django/core/     2007-07-10 16:55:07.000000000 +0800
+++ /usr/lib/python2.4/site-packages/django/core/  2007-07-10 16:37:27.000000000 +0800
@@ -65,7 +65,9 @@
         for model in models.get_models(app):
     if backend.uses_case_insensitive_names:
-        converter = str.upper
+        import string
+        converter = string.upper
         converter = lambda x: x
     return set([m for m in all_models if converter(m._meta.db_table) in map(converter, table_list)])

Change History (2)

comment:1 Changed 11 years ago by Chris Beaven

Component: UncategorizedCore framework
Keywords: unicode,oracle,strunicode oracle str
Owner: changed from Jacob to Adrian Holovaty
Triage Stage: UnreviewedReady for checkin

comment:2 Changed 11 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [5852]) Fixed #4827 -- Fixed a problem when converting Unicode table names to upper-case in Oracle backend. Based on a patch from timchen119@….

Note: See TracTickets for help on using tickets.
Back to Top