#28679: urlencode does not decode bytes before passing them to Python's 
urlencode
-------------------------------------+-------------------------------------
     Reporter:  François Freitag     |                    Owner:  François
                                     |  Freitag
         Type:  Bug                  |                   Status:  assigned
    Component:  Utilities            |                  Version:  2.0
     Severity:  Release blocker      |               Resolution:
     Keywords:  urlencode bytes      |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Jon Dufresne):

 > Python is ​bytes differently than other types, perhaps Django should
 maintain that behaviour?

 I see. Is this the only motivation or is there a use case? While I might
 disagree with Python's choice here, I understand the argument of following
 upstream and the wider community.

 > IMHO, decoding user-encoded bytes (assuming utf-8) and re-encoding is
 not useful and may cause harm to users who decided to encode their data
 using another encoding. I tend to agree with Claude on special-casing
 bytes.

 This is precisely what
 
[https://github.com/django/django/blob/9718fa2e8abe430c3526a9278dd976443d4ae3c6/django/utils/encoding.py#L51-L70
 force_text()] is doing. If decoding as utf-8 is causing harm, it hasn't
 been avoided.

 By using `force_text()` there is an implicit assumption that the bytes
 data is utf-8 encoded. While that may be true for a large majority of the
 cases, there is no reason to believe this is true for all cases. Having
 the bytes data properly decoded as it is received would avoid this
 assumption.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28679#comment:7>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.77a361822a9c7fedfe73119185f4ca54%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to