Martin Panter added the comment:
There is already a check for request.data being str in do_request_(). Maybe it
is okay to remove this check; I think it would be equivalent to the new check.
Regarding the dict check, here is a strange class that currently works, but
would be broken by the patch. Maybe it is okay to break it though, since it
certainly goes against the urlopen() documentation.
class ReaderMapping(dict):
def __init__(self):
super().__init__({"abc": "xyz"})
self.mode = "r"
self.data = "123"
def read(self, size):
data = self.data
self.data = ""
return data
urlopen(Request("http://localhost/", headers={"Content-Length": 3},
data=ReaderMapping()))
If we wanted to continue to support this kind of usage, perhaps the safest
option would be to change the test to “if type(data) is dict” rather than use
isinstance().
I also left a comment about eliminating urlencode() in the test.
----------
stage: needs patch -> patch review
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue25439>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com