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. |
|
|
msg100258 - (view) |
Author: Jeremy Hylton (jhylton)  |
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) *  |
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) *  |
Date: 2016-01-02 22:23 |
Thank you Ezio, I'll commit this tomorrow. |
|
|
msg257566 - (view) |
Author: Roundup Robot (python-dev)  |
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) *  |
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)  |
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) *  |
Date: 2016-01-06 01:10 |
Thanks, Senthil. I've just reverted fbea8ff8db5e. Sorry for the noise! |
|
|
msg257575 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
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) *  |
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)  |
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) *  |
Date: 2016-01-18 08:59 |
Thank you for the review Senthil. |
|
|