Opened 8 years ago

Closed 8 years ago

#4827 closed (fixed)

str.upper() failed in _get_installed_models when syncdb

Reported by: timchen119@… Owned by: adrian
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: UI/UX:



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 8 years ago by SmileyChris

  • Component changed from Uncategorized to Core framework
  • Keywords changed from unicode,oracle,str to unicode oracle str
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from jacob to adrian
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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