New submission from François Freitag <mail+pyt...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue31706>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to