cpython: d34fdd1736f2 (original) (raw)
Mercurial > cpython
changeset 99957:d34fdd1736f2 2.7
Issue #6500: Fixed infinite recursion in urllib2.Request.__getattr__(). [#6500]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Mon, 18 Jan 2016 10:35:40 +0200 |
parents | 668827be66d6 |
children | f602dfd35cd4 |
files | Lib/test/test_urllib2.py Lib/urllib2.py Misc/NEWS |
diffstat | 3 files changed, 10 insertions(+), 5 deletions(-)[+] [-] Lib/test/test_urllib2.py 5 Lib/urllib2.py 8 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1350,6 +1350,11 @@ class RequestTests(unittest.TestCase): req = Request(url) self.assertEqual(req.get_full_url(), url)
- def test_private_attributes(self):
self.assertFalse(hasattr(self.get, '_Request__r_xxx'))[](#l1.8)
# Issue #6500: infinite recursion[](#l1.9)
self.assertFalse(hasattr(self.get, '_Request__r_method'))[](#l1.10)
+ def test_HTTPError_interface(self): """ Issue 13211 reveals that HTTPError didn't implement the URLError
--- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -248,11 +248,9 @@ class Request: # methods getting called in a non-standard order. this may be # too complicated and/or unnecessary. # XXX should the __r_XXX attributes be public?
if attr[:12] == '_Request__r_':[](#l2.7)
name = attr[12:][](#l2.8)
if hasattr(Request, 'get_' + name):[](#l2.9)
getattr(self, 'get_' + name)()[](#l2.10)
return getattr(self, attr)[](#l2.11)
if attr in ('_Request__r_type', '_Request__r_host'):[](#l2.12)
getattr(self, 'get_' + attr[12:])()[](#l2.13)
return self.__dict__[attr][](#l2.14) raise AttributeError, attr[](#l2.15)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -39,6 +39,8 @@ Core and Builtins Library ------- +- Issue #6500: Fixed infinite recursion in urllib2.Request.getattr(). +