[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-07 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Looks good to me. I'd prefer 'test_long_as_size' to be called 'test_long_as_size_t' (even though that's inaccurate for the ssize_t bits :-). The 'Py_None' reference counting in test_long_as_size and test_long_as_double looked a little odd

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-07 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 4a66a35da3fd by Nadeem Vawda in branch 'default': Issue #12909: Make PyLong_As* functions consistent in their use of exceptions. http://hg.python.org/cpython/rev/4a66a35da3fd -- nosy: +python-dev

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-07 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: The 'Py_None' reference counting in test_long_as_size and test_long_as_double looked a little odd at first glance Indeed, it is rather roundabout, so I added a comment to avoid confusion. Anyway, those are just nitpicks; I leave it to

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-07 Thread Nadeem Vawda
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12909 ___

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-07 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: +1 -- assignee: nadeem.vawda - rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12909 ___

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Nadeem Vawda
New submission from Nadeem Vawda nadeem.va...@gmail.com: The C functions for converting a Python 'int' object to a C integer are inconsistent about what exception gets raised when the object passed to them is not an integer. Most of these functions raise a TypeError, but

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +mark.dickinson, rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12909 ___ ___

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: +1 for turning these into TypeErrors. It makes little sense that PyLong_AsLongLong and PyLong_AsUnsignedLongLong behave differently here. Do you have a patch handy? -- ___ Python tracker

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: Do you have a patch handy? See attached. -- keywords: +patch Added file: http://bugs.python.org/file23106/pylong-exceptions.diff ___ Python tracker rep...@bugs.python.org

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: This probably shouldn't be backported to 3.2; it could break 3rd-party extension modules (though I would hope that nothing depends on this behaviour...). Also, it's worth noting that the error handling between conversion functions still

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: This probably shouldn't be backported to 3.2 Agreed; I don't see this as a bugfix (especially since AFAIK it's not documented that TypeError should be raised here); rather, as a design improvement. Also, it's worth noting that the

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: The patch still needs tests (e.g., in test_capi). I'm not sure whether it would be good to add information about the TypeError to the docs. -- ___ Python tracker rep...@bugs.python.org

[issue12909] Inconsistent exception usage in PyLong_As* C functions

2011-09-06 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: Attached is an updated patch with tests. There don't seem to be any tests for PyLong_AsS[s]ize_t() and PyLong_AsDouble(), so I added new ones for this issue. They should still be expanded on at some point in the future, but for the