[issue7550] PyLong_As* methods should not call nb_int.

2009-12-21 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

It turns out this is intimately bound up with the behaviour of 
PyArg_ParseTuple* for integer format codes.  Since this behaviour can't 
change until Python 3.3 (because of the moratorium), I'm closing this for 
now.

--
resolution:  - later
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7550
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7550] PyLong_As* methods should not call nb_int.

2009-12-20 Thread Mark Dickinson

New submission from Mark Dickinson dicki...@gmail.com:

The following C-API functions:

PyLong_AsLongAndOverflow
PyLong_AsUnsignedLongMask
PyLong_AsLongLong
PyLong_AsUnsignedLongLongMask

call nb_int for inputs that don't satisfy PyLong_Check.  They thus accept 
floats, Decimal instances, etc.  They should probably call nb_index 
instead (or perhaps accept only instances of int).

The uses of these functions within the Python source should be checked, to 
see what consequences (if any) this change would have for Python 
semantics; it's possible that some of these consequences would fall under 
the moratorium (PEP 3003).  In any case, this change probably requires a 
1-release deprecation period.

--
components: Interpreter Core
messages: 96670
nosy: mark.dickinson
severity: normal
status: open
title: PyLong_As* methods should not call nb_int.
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7550
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7550] PyLong_As* methods should not call nb_int.

2009-12-20 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Since PyLong_AsLong goes through PyLong_AsLongAndOverflow, this change 
would also affect calls to PyLong_AsLong.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7550
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7550] PyLong_As* methods should not call nb_int.

2009-12-20 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Just as an experiment, I removed the calls to nb_int and ran the test-
suite.  The only test failures were in test_ctypes, test_getargs2, and 
test_math.

The test_math failure was from math.factorial depending on PyLong_AsLong 
to convert floats;  I've fixed this in r76916 (trunk) and r76917 (py3k).

One consequence of not having PyLong_AsLong automatically call nb_int 
would be that math.factorial(decimal.Decimal('-0.53')) is no longer valid.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7550
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com