summaryrefslogtreecommitdiffstats
path: root/Modules/_struct.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-04-04 08:43:04 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-04-04 08:43:04 (GMT)
commitfdaaa9c9d8a768c324a49250c91295ebce6b201a (patch)
tree2a3cbe6e2caac85e72fd9f1622a531828cbb2401 /Modules/_struct.c
parent0d57caa2678fcb5c08a247a9ed17c73b311c7c00 (diff)
downloadcpython-fdaaa9c9d8a768c324a49250c91295ebce6b201a.zip
cpython-fdaaa9c9d8a768c324a49250c91295ebce6b201a.tar.gz
cpython-fdaaa9c9d8a768c324a49250c91295ebce6b201a.tar.bz2
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.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c
index fe54a47..441da03 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);