Strange behaviour: subclass of int returns 3 when constructed with long
Gerrit Holl
gerrit at nl.linux.org
Sun Feb 9 11:58:56 EST 2003
Alex Martelli schreef op zondag 9 februari om 16:47:52 +0000:
> Gerrit Holl wrote:
> > 0 >>> class A(int): pass
> > 0 ...
> > 5 >>> A(sys.maxint+42)
> > 3
> In Python 2.3a1, this behavior is indeed reproducible on my
> system, too.
oops, should have mentioned that.
> > how can this behaviour be explained? Shouldn't A behave identical to int?
>
> int has acquired some magic to generate long instead when needed,
> as in your statement number 3. It apppears the magic isn't
> smoothly inherited in 2.3a1. You may want to signal this bug
> in the sourceforge bug tracker.
I have done that...
[examples]
> the first case exhibits the bug, the second one doesn't --
> so int.__new__ does seem to be the culprit here. It may
> be using (the C equivalent of) 'cls is int' to condition
> its magic, perhaps (haven't checked this in the 2.3a1
> Python C sources).
Ah, maybe. I will mention this message in a comment attached to the
bug-sumbit as soon as this message is archived.
yours,
Gerrit.
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
http://www.sp.nl/
More information about the Python-list
mailing list