New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
urllib2 maximum recursion depth exceeded #50749
Comments
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? |
That __getattr__ was removed in r70815 and in Python 3.1 it's OK. Assigning to Jeremy to see what he thinks about it. |
Ok. I'll take a look, too. Jeremy On Sat, Feb 27, 2010 at 4:30 AM, Ezio Melotti <report@bugs.python.org> wrote:
|
Here is a patch for 2.7. I don't think backporting 9eceb618274a to 2.7 is worth the effort for this, so I just fixed the __getattr__ method and added a test. |
Thank you Ezio, I'll commit this tomorrow. |
New changeset fbea8ff8db5e by Berker Peksag in branch '2.7': |
Hi @berker, This patch breaks the unit tests. Could you confirm (or reject) this? |
New changeset e2faa18802bb by Berker Peksag in branch '2.7': |
Thanks, Senthil. I've just reverted fbea8ff8db5e. Sorry for the noise! |
__getattr__() was purposed to handle two lazily created private attributes: __r_type and __r_host. They are set in corresponding get_-methods. Here is a patch that makes __getattr__() to handle only these attributes. |
@serhiy, the patch looks good to me. This change is an excellent idea. Please commit it. |
New changeset d34fdd1736f2 by Serhiy Storchaka in branch '2.7': |
Thank you for the review Senthil. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: