diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-04-04 08:43:04 +0000 |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-04-04 08:43:04 +0000 |
commit | cc99fc579145c236be6138e77eec72d857e8d947 (patch) | |
tree | 2daa57fc70def72aebf9af4ab41489bd17be680f /Modules/_struct.c | |
parent | 3a90dbf0b15c62b7238dd7eb7e25c6f828abcb59 (diff) | |
download | cpython-cc99fc579145c236be6138e77eec72d857e8d947.tar.gz |
Issue #8300 (__index__ handling in struct.pack): Remove redundant check
and improve test coverage. Thanks Meador Inge for the patch.
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r-- | Modules/_struct.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index fe54a47267..441da03151 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -123,12 +123,6 @@ get_pylong(PyObject *v) w = PyNumber_Index(v); if (w != NULL) { v = w; - if (!PyInt_Check(v) && !PyLong_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "__index__ method " - "returned non-integer"); - return NULL; - } /* successfully converted to an integer */ converted = 1; } @@ -175,6 +169,7 @@ get_pylong(PyObject *v) /* Ensure we own a reference to v. */ Py_INCREF(v); + assert(PyInt_Check(v) || PyLong_Check(v)); if (PyInt_Check(v)) { r = PyLong_FromLong(PyInt_AS_LONG(v)); Py_DECREF(v); |