[Python-bugs-list] [ python-Bugs-683467 ] 'int' ability to generate longs not inherited

SourceForge.net noreply@sourceforge.net
Sun, 09 Feb 2003 09:49:11 -0800


Bugs item #683467, was opened at 2003-02-09 11:59
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=683467&group_id=5470

Category: Type/class unification
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gerrit Holl (gerrit)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: 'int' ability to generate longs not inherited

Initial Comment:
[cvs update, ./configure, make]
$ ./python
Python 2.3a1 (#2, Feb  9 2003, 17:48:14)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
  0 >>> import sys
  1 >>> class A(int): pass
  1 ...
  2 >>> int(sys.maxint+1)
2147483648L
  3 >>> A(sys.maxint+1)
3
$ uname -a
Linux stopcontact 2.4.17 #1 Sat Jan 19 16:45:33 CET
2002 i686 unknown


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-02-09 12:49

Message:
Logged In: YES 
user_id=33168

Attached is a patch which fixes this problem.  If the value
is a PyLong, try to get the int out of it (int values
proceed as before).  Otherwise, raise a ValueError, "value
must convertable to an int".  Not sure if that exception is
really reachable, since it depends on what int_new() returns
(usually return PyNumber_Int).

If this is acceptable, I'll update NEWS too.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-02-09 12:13

Message:
Logged In: YES 
user_id=33168

Wait, it gets better with a debug build:

python: Objects/intobject.c:844: int_subtype_new: Assertion
`((tmp)->ob_type == (&PyInt_Type) ||
PyType_IsSubtype((tmp)->ob_type, (&PyInt_Type)))' failed.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=683467&group_id=5470