This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients Nan Wu, ezio.melotti, martin.panter
Date 2015-10-27.05:18:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1445923122.1.0.532852696458.issue25439@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-10-27 05:18:42martin.pantersetrecipients: + martin.panter, ezio.melotti, Nan Wu
2015-10-27 05:18:42martin.pantersetmessageid: <1445923122.1.0.532852696458.issue25439@psf.upfronthosting.co.za>
2015-10-27 05:18:42martin.panterlinkissue25439 messages
2015-10-27 05:18:40martin.pantercreate