classification
Title: urllib2 maximum recursion depth exceeded
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: pending Resolution:
Dependencies: Superseder:
Assigned To: jhylton Nosy List: ezio.melotti, jhylton, nako521 (3)
Priority: normal Keywords

Created on 2009-07-17 08:26 by nako521, last changed 2009-07-17 09:19 by ezio.melotti.

Messages (2)
msg90612 - (view) Author: simon (nako521) Date: 2009-07-17 08:26
def __getattr__(self, attr):
        # XXX this is a fallback mechanism to guard against these
        # 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_':
            name = attr[12:]
            if hasattr(Request, 'get_' + name):
                getattr(self, 'get_' + name)()
                return getattr(self, attr)
        raise AttributeError, attr

this may cause "maximum recursion depth exceeded"

>>> import urllib2
>>> req = urllib2.Request('http://www.nbc.com')
>>> req._Request__r_method
RuntimeError: maximum recursion depth exceeded

"return getattr(self, attr)"? should it be removed?
msg90615 - (view) Author: Ezio Melotti (ezio.melotti) Date: 2009-07-17 09:19
That __getattr__ was removed in r70815 and in Python 3.1 it's OK.
The change wasn't backported to the trunk though.

Assigning to Jeremy to see what he thinks about it.
History
Date User Action Args
2009-07-17 09:19:21ezio.melottisetstatus: open -> pending


nosy: + jhylton, ezio.melotti
versions: + Python 2.7, - Python 2.6, Python 2.5, Python 2.4
messages: + msg90615
priority: normal
assignee: jhylton
2009-07-17 08:26:12nako521create