[Python-3000-checkins] r62462 - in python/branches/py3k: Lib/test/test_getargs2.py Python/getargs.c
trent.nelson
python-3000-checkins at python.org
Tue Apr 22 21:02:41 CEST 2008
Author: trent.nelson
Date: Tue Apr 22 21:02:40 2008
New Revision: 62462
Log:
Issue 2440: remove the guard around the handling of case 'n' in getargs.c's convertsimple() such that we always treat it as an index type, regardless of whether or not sizeof(size_t) == sizeof(long). Fix the test_args2.Signed_TestCase.test_n() such that it tests for adherence to PEP 357 (don't try and coerce objects that don't have nb_index slots but do have nb_int slots (i.e. floats) into indexes 'just because we can'). Three other commits are related to this one: r62269 and r62279, which were changes to PyNumber_Index (among other things) to check for nb_int slots when we lack nb_index slots -- and r62292, which is when I reverted these changes after various people pointed out that the test was in fact wrong, not the code.
Modified:
python/branches/py3k/Lib/test/test_getargs2.py
python/branches/py3k/Python/getargs.c
Modified: python/branches/py3k/Lib/test/test_getargs2.py
==============================================================================
--- python/branches/py3k/Lib/test/test_getargs2.py (original)
+++ python/branches/py3k/Lib/test/test_getargs2.py Tue Apr 22 21:02:40 2008
@@ -187,8 +187,8 @@
# n returns 'Py_ssize_t', and does range checking
# (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX)
self.assertRaises(TypeError, getargs_n, 3.14)
- self.failUnlessEqual(99, getargs_n(Long()))
- self.failUnlessEqual(99, getargs_n(Int()))
+ self.assertRaises(TypeError, getargs_n, Long())
+ self.assertRaises(TypeError, getargs_n, Int())
self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1)
self.failUnlessEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN))
Modified: python/branches/py3k/Python/getargs.c
==============================================================================
--- python/branches/py3k/Python/getargs.c (original)
+++ python/branches/py3k/Python/getargs.c Tue Apr 22 21:02:40 2008
@@ -663,7 +663,6 @@
}
case 'n': /* Py_ssize_t */
-#if SIZEOF_SIZE_T != SIZEOF_LONG
{
PyObject *iobj;
Py_ssize_t *p = va_arg(*p_va, Py_ssize_t *);
@@ -672,14 +671,12 @@
return converterr("integer<n>", arg, msgbuf, bufsize);
iobj = PyNumber_Index(arg);
if (iobj != NULL)
- ival = PyLong_AsSsize_t(arg);
+ ival = PyLong_AsSsize_t(iobj);
if (ival == -1 && PyErr_Occurred())
return converterr("integer<n>", arg, msgbuf, bufsize);
*p = ival;
break;
}
-#endif
- /* Fall through from 'n' to 'l' if Py_ssize_t is int */
case 'l': {/* long int */
long *p = va_arg(*p_va, long *);
long ival;
More information about the Python-3000-checkins
mailing list