Strange behaviour: subclass of int returns 3 when constructed with long
gerrit at nl.linux.org
Sun Feb 9 17:58:56 CET 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...
> 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.
Asperger Syndroom - een persoonlijke benadering:
Het zijn tijden om je zelf met politiek te bemoeien:
More information about the Python-list