#18063: repr() should return only ascii, not unicode
-------------------------------------+-------------------------------------
     Reporter:  guettli              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |               Resolution:  wontfix
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by kmtracey):

 * status:  reopened => closed
 * resolution:   => wontfix


Comment:

 Django code that generates an exception when handed a bytestring which
 contains non-ASCII characters is broken. '''That''' is the code that
 should be fixed. I strongly believe changing Model `__repr__` to avoid
 putting non-ASCII characters in it is the wrong approach. It is
 sidestepping a problem rather than fixing the source (or sources) of the
 problem.

 Bytestrings are ambiguous, yes. You need to rely on some other information
 to know how to properly decode bytestrings. However, in Python 2
 `__repr__` must return a bytestring, therefore Django must encode to
 something. The overall approach taken by Django, consistently, when
 unicode support was added, was to "assume utf-8" wherever a bytestring has
 to be decoded/encoded and the "correct" encoding is unknown. Returning a
 utf-8 encoded bytestring from `__repr__` is consistent with this overall
 approach. I don't believe it should be changed.

 I'm closing this wontfix. If you can lay out a case (or cases) where non-
 ASCII data in `__repr__` leads to exceptions caused by Django code, then
 we should fix those issues. But I don't believe the fixes will require
 changing the behavior of `__repr__`, and the original description and
 discussion so far here has focused solely on `__repr__`, which is the
 wrong place to look. Therefore please open a new ticket (or tickets) to
 address issues found where Django code cannot correctly handle non-ASCII
 data in `__repr__`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18063#comment:15>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to