[New-bugs-announce] [issue3777] PyNumber_Long fails from Float

Barry Alan Scott report at bugs.python.org
Thu Sep 4 22:49:17 CEST 2008

New submission from Barry Alan Scott <barry-scott at users.sourceforge.net>:

I am testing PySVN against python2.6b3.

I see a failure when PyNumber_Long is called with a Float.
It raises TypeError.

The same code works on 2.3, 2.4 and 2.5.

Looking with GDB I see:

(gdb) bt
#0  PyNumber_Long (o=0x1809384) at Objects/abstract.c:1735
#1  0x020f8e70 in Py::Long::Long (this=0xbfffefc8, ob=@0xbfffefc0) at

1681            m = o->ob_type->tp_as_number;
1682            if (m && m->nb_long) { /* This should include subclasses
of long */
1683                    /* Classic classes always take this branch. */
1684                    PyObject *res = m->nb_long(o);
1685                    if (res && (!PyInt_Check(res) &&
!PyLong_Check(res))) {

res does not contain the value that nb_long(o) calculated.
and the if on 1685 is false so you get a type error.

I have compiled on Mac OS X 10.4 powerpc and fedora 8 x86.
Both fail in the exact same way.

If you need to reproduce you will need to build pysvn and
run a command that triggers the problem. I don't have a
smaller example.

components: None
messages: 72519
nosy: barry-scott
severity: normal
status: open
title: PyNumber_Long fails from Float
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list