[issue9869] long_subtype_new segfault in pure-Python code
Mark Dickinson
report at bugs.python.org
Sat Sep 18 12:48:36 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
Problem confirmed here; thanks for the report.
I think it's also a bug that after:
class A(object):
def __long__(self):
return 42
long(A()) returns an object of type 'int' rather than an object of type 'long'. It's inconsistent with what happens with __trunc__, too:
>>> class A(object):
... def __trunc__(self): return 42
...
[37198 refs]
>>> long(A())
42L
[37201 refs]
What's a little bit odd is that there's a test for the __long__-returning-int behaviour in test_class that asserts the return type should be int.
Here's a patch that fixes the return type of long (and PyNumber_Long) to be long in these cases.
----------
keywords: +patch
Added file: http://bugs.python.org/file18918/issue9869.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9869>
_______________________________________
More information about the Python-bugs-list
mailing list