A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-August/135725.html below:

[Python-Dev] python2.7 infinite recursion when loading pickled object

[Python-Dev] python2.7 infinite recursion when loading pickled object [Python-Dev] python2.7 infinite recursion when loading pickled objectPeter Otten __peter__ at web.de
Mon Aug 11 13:40:13 CEST 2014
Terry Reedy wrote:

> On 8/11/2014 5:10 AM, Schmitt Uwe (ID SIS) wrote:
> 
> Python usage questions should be directed to python-list, for instance.
> 
>> I discovered a problem using cPickle.loads from CPython 2.7.6.
> 
> The problem is your code having infinite recursion. You only discovered
> it with pickle.
> 
> 
>> The last line in the following code raises an infinite recursion
>>
>>      class T(object):
>>
>>          def __init__(self):
>>              self.item = list()
>>
>>          def __getattr__(self, name):
>>              return getattr(self.item, name)
> 
> This is a (common) bug in your program.  __getattr__ should call
> self.__dict__(name) to avoid the recursion.

Read again. The OP tries to delegate attribute lookup to an (existing) 
attribute.

IMO the root cause of the problem is that pickle looks up __dunder__ methods 
in the instance rather than the class.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4