#30485: Unexpected behavior for django.utils.http.urlencode
----------------------------------------+------------------------
               Reporter:  jlubcke       |          Owner:  nobody
                   Type:  Bug           |         Status:  new
              Component:  Core (Other)  |        Version:  2.2
               Severity:  Normal        |       Keywords:
           Triage Stage:  Unreviewed    |      Has patch:  0
    Needs documentation:  0             |    Needs tests:  0
Patch needs improvement:  0             |  Easy pickings:  0
                  UI/UX:  0             |
----------------------------------------+------------------------
 The function django.utils.http.urlencode has been changed to give
 unexpected result for tuple values (and other iterable objects) in the
 case when no iterations is expected:
 {{{
 >>> django.utils.http.urlencode(dict(a=('a','b')), doseq=False)
 'a=%5B%27a%27%2C+%27b%27%5D'
 }}}

 One would expect the same as the standard library version (Note the first
 and last characters has been replaced by square brackets):
 {{{
 >>> urllib.parse.urlencode(dict(a=('a', 'b')), doseq=False)
 'a=%28%27a%27%2C+%27b%27%29'
 }}}

 If the value is a list, the result if what one would expect:
 {{{
 >>> django.utils.http.urlencode(dict(a=['a','b']), doseq=False)
 'a=%5B%27a%27%2C+%27b%27%5D'
 >>> urllib.parse.urlencode(dict(a=['a', 'b']), doseq=False)
 'a=%5B%27a%27%2C+%27b%27%5D'
 }}}

 Note: This is a problem when one has objects that has a `__str__` method
 defined, returning the value one would want to be in the urlencode result,
 but the object by coincidence is also iterable.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30485>
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/050.7b7bcab19d7c2c19c4bcfc81c75b5515%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to