[New-bugs-announce] [issue1666] integer subclass range behavior

Joseph Armbruster report at bugs.python.org
Thu Dec 20 04:39:42 CET 2007


New submission from Joseph Armbruster:

I was wondering what would happen, so I tried this out for the heck of
it with:

Python 3.0a2 (py3k:59572M, Dec 19 2007, 15:54:07) [MSC v.1500 32 bit
(Intel)]
on win32

class a(int):
   def __new__(cls,number):
     return int.__new__(cls,number)
for x in range(0,a(5)):
  print(x)


This resulted in a:
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "a.py", line 5, in <module>
     for x in range(0,a(5)):
SystemError: ..\Objects\longobject.c:400: bad argument to internal
function
[41030 refs]

It looks like the rangeobject performs a FitsInLong test on each of
the parameters to range, which uses the function
_PyLong_FitsInLong(PyObject *vv) within longobject.c.  In tern, this
performs a typecheck:  #define PyLong_CheckExact(op) (Py_TYPE(op) ==
&PyLong_Type) that fails.

----------
components: Interpreter Core
messages: 58852
nosy: JosephArmbruster
severity: normal
status: open
title: integer subclass range behavior
type: crash
versions: Python 3.0

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1666>
__________________________________


More information about the New-bugs-announce mailing list