Opened 9 years ago

Closed 9 years ago

Last modified 7 weeks ago

#12892 closed (fixed)

UnicodeEncodeError in contrib.admindocs with non-EN locale

Reported by: Beuc Owned by: nobody
Component: Internationalization Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

I have this in my

    (r'^admin/doc/', include('django.contrib.admindocs.urls')),

and this in my

# (same with 'fr-fr')

If I go to http://localhost:8000/admin/doc/models/auth.user/

I get:

Unicode error hint

The string that could not be encoded/decoded was: <modèle :u


Request Method: GET
Request URL: http://localhost:8000/admin/doc/models/auth.user/
Django Version: 1.1.1
Python Version: 2.5.5
Installed Applications:
Installed Middleware:

File "/usr/lib/pymodules/python2.5/django/core/handlers/" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/pymodules/python2.5/django/contrib/admin/views/" in _checklogin
  33.             return view_func(request, *args, **kwargs)
File "/usr/lib/pymodules/python2.5/django/contrib/admindocs/" in model_detail
  228.             'verbose': utils.parse_rst(_("all %s") % verbose , 'model', _('model:') + opts.module_name),
File "/usr/lib/pymodules/python2.5/django/contrib/admindocs/" in parse_rst
  70.                 settings_overrides=overrides)
File "/usr/lib/pymodules/python2.5/docutils/" in publish_parts
  432.         enable_exit_status=enable_exit_status)
File "/usr/lib/pymodules/python2.5/docutils/" in publish_programmatically
  646.     output = pub.publish(enable_exit_status=enable_exit_status)
File "/usr/lib/pymodules/python2.5/docutils/" in publish
  203.                                              self.settings)
File "/usr/lib/pymodules/python2.5/docutils/readers/" in read
  69.         self.parse()
File "/usr/lib/pymodules/python2.5/docutils/readers/" in parse
  74.         self.document = document = self.new_document()
File "/usr/lib/pymodules/python2.5/docutils/readers/" in new_document
  80.         document = utils.new_document(self.source.source_path, self.settings)
File "/usr/lib/pymodules/python2.5/docutils/" in new_document
  426.     source_path = decode_path(source_path)
File "/usr/lib/pymodules/python2.5/docutils/" in decode_path
  340.         path = path.decode(sys.getfilesystemencoding(), 'strict')
File "/usr/lib/python2.5/encodings/" in decode
  16.     return codecs.utf_8_decode(input, errors, True)

Exception Type: UnicodeEncodeError at /admin/doc/models/auth.user/
Exception Value: 'ascii' codec can't encode character u'\xe8' in position 4: ordinal not in range(128)

If I switch to:


the problem disappears.

It looks like the translated string is not properly declared as Unicode.

Change History (5)

comment:1 Changed 9 years ago by Beuc

This might be related to docutils, because:

  • under Debian Lenny (docutils 0.5-2) there's no problem
  • under Debian Squeeze (docutils 0.6-3) there's the bug

comment:2 Changed 9 years ago by Ramiro Morales

Description: modified (diff)

Re-formated description. Please use preview (and WikiFormatting for complex descriptions) as suggested in the notes displayed before you open a ticket.

comment:3 Changed 9 years ago by Russell Keith-Magee

Component: django.contrib.adminInternationalization
Triage Stage: UnreviewedAccepted

comment:4 Changed 9 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

(In [13192]) Fixed #12892 - Fixed unicode related bug in a utility function of the admindocs app that prevented it to be used in non-English environments together with certain versions of docutils.

comment:5 Changed 7 weeks ago by Tim Graham <timograham@…>

Easy pickings: unset
UI/UX: unset

In d4fc111c:

Refs #27795 -- Removed force_bytes() usage in admindocs.

Refs #12892 is probably obsolete.

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