[New-bugs-announce] [issue31706] urlencode should accept generator as values for mappings when doseq=True
François Freitag
report at bugs.python.org
Thu Oct 5 16:12:52 EDT 2017
New submission from François Freitag <mail+python at franek.fr>:
The urlencode documentation states that:
The value element in itself can be a sequence and in that case, if the optional parameter doseq is evaluates to True, individual key=value pairs separated by '&' are generated for each element of the value sequence for the key.
Passing a generator as the value gives unexpected results:
>>> from urllib.parse import urlencode
>>> def gen():
... yield from range(2)
>>> urlencode({'a': gen()}, doseq=True)
'a=%3Cgenerator+object+gen+at+0x7f35ff78db48%3E'
A list gives:
>>> urlencode({'a': [0, 1]}, doseq=True)
'a=0&a=1'
----------
components: Library (Lib)
messages: 303784
nosy: freitafr
priority: normal
severity: normal
status: open
title: urlencode should accept generator as values for mappings when doseq=True
type: enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31706>
_______________________________________
More information about the New-bugs-announce
mailing list