[issue2138] Add a factorial function
Mark Dickinson
report at bugs.python.org
Wed Jun 18 02:02:05 CEST 2008
Mark Dickinson <dickinsm at gmail.com> added the comment:
It looks like there's a refcounting bug in the code: if the call to
PyNumber_Multiply fails then iobj gets DECREF'd twice. This means that a
keyboard interrupt of factorial() can exit the interpreter:
Python 2.6a3+ (trunk:64341M, Jun 17 2008, 13:19:01)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from math import factorial
[36374 refs]
>>> factorial(10**9)
^CFatal Python error:
/Users/dickinsm/python_source/trunk/Modules/mathmodule.c:562 object at
0x81f63c has negative ref count -1
Abort trap
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2138>
_______________________________________
More information about the Python-bugs-list
mailing list