why does this fail on python 2.2?

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Aug 30 10:21:31 EDT 2004


I'm trying to understand why some code from a module I'm using is
failing on 2.3 but working on 2.3.  Here is the minimal example that
replicates the problem

class Results(object):
    __slots__ = ( "__doinit" )
    def __new__(cls):
        retobj = object.__new__(cls)
        retobj.__doinit = True
        return retobj

x = Results()

On python2.2, this fails with

mother:~/tmp> python2.2 test.py
Traceback (most recent call last):
  File "test.py", line 8, in ?
    x = Results()
  File "test.py", line 5, in __new__
    retobj.__doinit = True
AttributeError: 'Results' object has no attribute '_Results__doinit'



More information about the Python-list mailing list