Issue 6500: urllib2 maximum recursion depth exceeded (original) (raw)

Created on 2009-07-17 08:26 by nako521, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue6500.diff berker.peksag,2015-08-03 00:41
issue6500_2.patch serhiy.storchaka,2016-01-06 01:56 review
Messages (13)
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) * (Python committer) 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.
msg100258 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2010-03-01 16:36
Ok. I'll take a look, too. Jeremy On Sat, Feb 27, 2010 at 4:30 AM, Ezio Melotti <report@bugs.python.org> wrote: > > Changes by Ezio Melotti <ezio.melotti@gmail.com>: > > > ---------- > nosy: +orsenthil > status: pending -> open > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue6500> > _______________________________________ >
msg247916 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-08-03 00:41
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.
msg257373 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-01-02 22:23
Thank you Ezio, I'll commit this tomorrow.
msg257566 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-06 00:05
New changeset fbea8ff8db5e by Berker Peksag in branch '2.7': Issue #6500: Fix "maximum recursion depth exceeded" error caused by Request.__getattr__() https://hg.python.org/cpython/rev/fbea8ff8db5e
msg257569 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2016-01-06 00:19
Hi @Berker, This patch breaks the unit tests. Could you confirm (or reject) this? Thanks
msg257572 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-06 01:08
New changeset e2faa18802bb by Berker Peksag in branch '2.7': Issue #6500: Reverting fbea8ff8db5e since it broke tests https://hg.python.org/cpython/rev/e2faa18802bb
msg257573 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-01-06 01:10
Thanks, Senthil. I've just reverted fbea8ff8db5e. Sorry for the noise!
msg257575 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-06 01:56
__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.
msg258495 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2016-01-18 03:28
@Serhiy, the patch looks good to me. This change is an excellent idea. Please commit it.
msg258504 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-18 08:40
New changeset d34fdd1736f2 by Serhiy Storchaka in branch '2.7': Issue #6500: Fixed infinite recursion in urllib2.Request.__getattr__(). https://hg.python.org/cpython/rev/d34fdd1736f2
msg258506 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-18 08:59
Thank you for the review Senthil.
History
Date User Action Args
2022-04-11 14:56:51 admin set github: 50749
2016-01-18 08:59:33 serhiy.storchaka set status: open -> closedresolution: fixedmessages: + stage: commit review -> resolved
2016-01-18 08:40:50 python-dev set messages: +
2016-01-18 03:28:23 orsenthil set assignee: berker.peksag -> serhiy.storchakamessages: + stage: patch review -> commit review
2016-01-06 01:56:14 serhiy.storchaka set files: + issue6500_2.patchnosy: + serhiy.storchakamessages: + stage: needs patch -> patch review
2016-01-06 01:10:02 berker.peksag set status: closed -> openresolution: fixed -> (no value)messages: + stage: resolved -> needs patch
2016-01-06 01:08:21 python-dev set messages: +
2016-01-06 00:19:43 orsenthil set messages: +
2016-01-06 00:05:36 berker.peksag set status: open -> closedresolution: fixedstage: commit review -> resolved
2016-01-06 00:05:01 python-dev set nosy: + python-devmessages: +
2016-01-02 22:23:14 berker.peksag set assignee: jhylton -> berker.peksagmessages: +
2016-01-01 23:20:48 ezio.melotti set stage: patch review -> commit review
2015-08-03 00:41:45 berker.peksag set files: + issue6500.diffnosy: + berker.peksagmessages: + keywords: + patchstage: needs patch -> patch review
2012-11-18 21:08:22 ezio.melotti set stage: needs patch
2010-03-01 16:36:04 jhylton set messages: +
2010-02-27 09:30:10 ezio.melotti set status: pending -> opennosy: + orsenthil
2009-07-17 09:19:21 ezio.melotti set status: open -> pendingpriority: normalassignee: jhyltonversions: + Python 2.7, - Python 2.6, Python 2.5, Python 2.4nosy: + jhylton, ezio.melottimessages: +
2009-07-17 08:26:12 nako521 create