Message72681
O.k. I know what is going on.
Here is the description from abstracts.h for PyNumber_Long:
PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o);
/*
Returns the o converted to a long integer object on success,
or NULL on failure. This is the equivalent of the Python
expression: long(o).
*/
Its says that I can expect a long integer. However PyNumber_long
can return an int or a long.
PyCXX checks for a long, but an int is not a long and I raise
a type error.
This is a contract break on the Python API.
The change that causes this break is in floatobject.c
From 2.5.2 code:
static PyNumberMethods float_as_number = {
...
float_int, /*nb_int*/
float_long, /*nb_long*/
From 2.6b3 code:
static PyNumberMethods float_as_number = {
...
float_trunc, /*nb_int*/
float_trunc, /*nb_long*/
float_trunc returns either an int or a long.
Which is not what is required for the API.
Here is the same bug at the pure python level.
$ python2.6
Python 2.6b3 (r26b3:65922, Aug 25 2008, 15:44:46)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> long(4)
4L
>>> long(4.3)
4
>>> long("6")
6L
>>> type(long(4.3))
<type 'int'>
>>>
Barry |
|
Date |
User |
Action |
Args |
2008-09-06 18:36:05 | barry-scott | set | recipients:
+ barry-scott, amaury.forgeotdarc |
2008-09-06 18:36:05 | barry-scott | set | messageid: <1220726165.24.0.703570814555.issue3777@psf.upfronthosting.co.za> |
2008-09-06 18:36:03 | barry-scott | link | issue3777 messages |
2008-09-06 18:36:03 | barry-scott | create | |
|