diff options
author | Trent Nelson <trent.nelson@snakebite.org> | 2008-04-22 19:02:40 (GMT) |
---|---|---|
committer | Trent Nelson <trent.nelson@snakebite.org> | 2008-04-22 19:02:40 (GMT) |
commit | 3513358e11df32cc02047e48a9a9a976343ba16c (patch) | |
tree | dd5d4343a4ceaaa6c028ef1feaa359a19edd90bc /Python | |
parent | b9e2304c445b04b6199b663ae70315fc115f036f (diff) | |
download | cpython-3513358e11df32cc02047e48a9a9a976343ba16c.zip cpython-3513358e11df32cc02047e48a9a9a976343ba16c.tar.gz cpython-3513358e11df32cc02047e48a9a9a976343ba16c.tar.bz2 |
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.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/getargs.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 1370e09..6a50ef6 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,12 @@ 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; |