Ticket #1024 (accepted defect)

Opened 3 years ago

Last modified 3 years ago

retry_failed_fields methods fails to produce meaningfull error if exception message contains unicode chars

Reported by: jbzdak@… Owned by: andrew
Priority: major Milestone: 1.0
Component: commands Version: unknown
Keywords: Cc:

Description

Method south.orm.FakeOrm.retry_failed_field fails to produce meaningfull error if field raises exception that contains unicode chars during creation.

Faulty code is

   try:
       field = self.eval_in_context(code, app, extra_imports)
   except (NameError, AttributeError, AssertionError, KeyError), e:
       # It's failed again. Complain.
       raise ValueError("Cannot successfully create field '%s' for model '%s': %s." % (
           fname, modelname, e
       ))

You should either use unicode pattern:

raise ValueError(u"Cannot successfully create field '%s' for model '%s': %s." % (
           fname, modelname, e
       ))

or use repr:

raise ValueError(u"Cannot successfully create field '%s' for model '%s': %s." % (
           fname, modelname, repr(e)
       ))

Full stack trace:

Traceback (most recent call last):
  File "/home/jb/ides/pycharm-2.0.1/helpers/pydev/pydevd.py", line 1325, in <module>
    debugger.run(setup['file'], None, None)
  File "/home/jb/ides/pycharm-2.0.1/helpers/pydev/pydevd.py", line 1033, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "/home/jb/programs/drat/hajmon/hajmondjango/manage.py", line 15, in <module>
    execute_manager(settings)
  File "/usr/lib/python2.6/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/lib/python2.6/dist-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/dist-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/dist-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/management/commands/migrate.py", line 105, in handle
    ignore_ghosts = ignore_ghosts,
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/__init__.py", line 191, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 221, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 292, in migrate_many
    result = self.migrate(migration, database)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 125, in migrate
    result = self.run(migration)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 93, in run
    south.db.db.current_orm = self.orm(migration)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 246, in orm
    return migration.orm()
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/utils.py", line 62, in method
    value = function(self)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/base.py", line 422, in orm
    return FakeORM(self.migration_class(), self.app_label())
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/orm.py", line 46, in FakeORM
    _orm_cache[args] = _FakeORM(*args)  
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/orm.py", line 132, in __init__
    self.retry_failed_fields()
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/orm.py", line 371, in retry_failed_fields
    fname, modelname, e

Change History

comment:1 Changed 3 years ago by andrew

  • Status changed from new to accepted
  • Milestone set to 1.0
Note: See TracTickets for help on using tickets.