You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ethanfurman'closed_at=Nonecreated_at=<Date2018-03-08.06:57:47.318>labels= ['3.8', 'type-bug', 'library', '3.9', '3.10']
title='urlencode produces bad output from ssl.CERT_NONE and friends that chokes decoders'updated_at=<Date2021-06-29.20:16:30.558>user='https://github.com/vitaly-krugl'
In [9]: from urllib.parse import urlencode, parse_qs
In [10]: import ast, ssl
In [11]: d = dict(cert_reqs=ssl.CERT_NONE)
In [12]: urlencode(d)
Out[12]: 'cert_reqs=VerifyMode.CERT_NONE'
In [25]: parse_qs('cert_reqs=VerifyMode.CERT_NONE')
Out[25]: {'cert_reqs': ['VerifyMode.CERT_NONE']}
In [29]: ast.literal_eval('VerifyMode.CERT_NONE')
Traceback (most recent call last)
...
ValueError: malformed node or string: <_ast.Attribute object at 0x105c22358>
This used to work fine and produce 'cert_reqs=0' on Python 2.7, allowing it to be decoded properly downstream. However, 'cert_reqs=VerifyMode.CERT_NONE' can't be decoded generically. So, something it's that used to work in prior python versions that is breaking now.
Additional information. json.dumps() actually dumps that value as a number instead of 'VerifyMode.CERT_NONE'.
It appears that urlencode doesn't work properly with enums, where I would expect it to emit the numeric value of the enum.
Actually, I think it uses str(). An easy fix would be to use format() for all non-bytes objects instead -- the question then becomes how many objects (besides Enums with mixed-in data types) have a different str() vs format() display?
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: