[Python-3000] getargs_n(), take two.
Trent Nelson
tnelson at onresolve.com
Sat Apr 12 03:31:08 CEST 2008
I reverted the changes from r62269 and r62279 in r62292. Any issues with the following patch? Note the removal of the guards around case 'n'; this will be the first time a lot of platforms will see this particular code path, as we're not falling back to 'l' anymore.
Index: Python/getargs.c
===================================================================
--- Python/getargs.c (revision 62292)
+++ Python/getargs.c (working copy)
@@ -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;
Index: Lib/test/test_getargs2.py
===================================================================
--- Lib/test/test_getargs2.py (revision 62292)
+++ Lib/test/test_getargs2.py (working copy)
@@ -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))
More information about the Python-3000
mailing list