summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTrent Nelson <trent.nelson@snakebite.org>2008-04-10 16:25:37 (GMT)
committerTrent Nelson <trent.nelson@snakebite.org>2008-04-10 16:25:37 (GMT)
commite2ae4684a5617ec5bc8d48e09af2dd7a24711f23 (patch)
tree4b065c8f03e00df65181af57df668136d3d8f0ed /Python
parent5680d0c5e3a9d42b6c21f4a31a7dbfe72c9e5170 (diff)
downloadcpython-e2ae4684a5617ec5bc8d48e09af2dd7a24711f23.zip
cpython-e2ae4684a5617ec5bc8d48e09af2dd7a24711f23.tar.gz
cpython-e2ae4684a5617ec5bc8d48e09af2dd7a24711f23.tar.bz2
Issue 2440: fix the handling of %n in Python/getargs.c's convertsimple(), extend Objects/abstract.c's PyNumber_Index() to accept PyObjects that have nb_int slots, and update test_getargs2 to test that an exception is thrown when __int__() returns a non-int object.
Diffstat (limited to 'Python')
-rw-r--r--Python/getargs.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 1370e09..960c68c 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -663,7 +663,6 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
}
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,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
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;