Skip to content

UnicodeDecodeError on save of model instance with non-ASCII bytestring field value #422

Closed
@kmtracey

Description

@kmtracey

environment: Django 1.5.4, Python 2..7.3

dev level debug toolbar is raising UnicodeDecodeError on save of a model instance where one of the field values in the model instance being saved is a bytestring containing non-ASCII characters. End of traceback is:

File "/home/kmtracey/projects/ccsr/ccsr_sam/sam/survey/forms.py" in save
  76.                 self.instance.save()
File "/home/kmtracey/projects/ccsr/ccsr_sam/sam/survey/models.py" in save
  252.         super(Survey, self).save(*args, **kwargs)
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/django/db/models/base.py" in save
  546.                        force_update=force_update, update_fields=update_fields)
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base
  626.                             rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/django/db/models/query.py" in _update
  605.         return query.get_compiler(self.db).execute_sql(None)
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1014.         cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  840.         cursor.execute(sql, params)
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/debug_toolbar/utils/tracking/db.py" in execute
  140.                     self.cursor, sql, self._quote_params(params)),
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/debug_toolbar/utils/tracking/db.py" in _quote_params
  87.         return list(map(self._quote_expr, params))
File "/home/kmtracey/.virtualenvs/ccsr1.5/local/lib/python2.7/site-packages/debug_toolbar/utils/tracking/db.py" in _quote_expr
  76.             element = element.replace("'", "''")

Exception Type: UnicodeDecodeError at /uccsparent/survey/dashboard/parent/
Exception Value: 'ascii' codec can't decode byte 0xe2 in position 6782: ordinal not in range(128)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions