why does this fail on python 2.2?

J

John Hunter

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'
 
R

Rob Williscroft

John Hunter wrote in (e-mail address removed) in comp.lang.python:
class Results(object):
__slots__ = ( "__doinit" )
def __new__(cls):

AttributeError: 'Results' object has no attribute '_Results__doinit'

Its in the Traceback:

__slots__ = [ '_Results__doinit' ]

Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top