Message185913
When calling urllib.urlopen with a string containing the NULL ('\x00') character, a TypeError exception is thrown, as in the following example:
urllib.urlopen('\x00\x00\x00')
[...]
File "/home/bucur/onion/python-bin/lib/python2.7/urllib.py", line 86, in urlopen
return opener.open(url)
File "/home/bucur/onion/python-bin/lib/python2.7/urllib.py", line 207, in open
return getattr(self, name)(url)
File "/home/bucur/onion/python-bin/lib/python2.7/urllib.py", line 462, in open_file
return self.open_local_file(url)
File "/home/bucur/onion/python-bin/lib/python2.7/urllib.py", line 474, in open_local_file
stats = os.stat(localname)
TypeError: must be encoded string without NULL bytes, not str
This exception is confusing, since apparently the right type (a string) is passed to the function. Since this behavior cannot change, it would be good to mention this exception in the function documentation.
I can imagine code that composes a URL based on user-supplied input and passes it to urlopen crashing if it doesn't properly sanitize the URL and/or doesn't catch TypeError. |
|
Date |
User |
Action |
Args |
2013-04-03 10:45:06 | Stefan.Bucur | set | recipients:
+ Stefan.Bucur |
2013-04-03 10:45:05 | Stefan.Bucur | set | messageid: <1364985905.97.0.615690774313.issue17624@psf.upfronthosting.co.za> |
2013-04-03 10:45:05 | Stefan.Bucur | link | issue17624 messages |
2013-04-03 10:45:05 | Stefan.Bucur | create | |
|