diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/cfield.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 03aacbd..155e75e 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -346,10 +346,9 @@ static int get_long(PyObject *v, long *p) { long x; - if (!PyInt_Check(v) && !PyLong_Check(v)) { - PyErr_Format(PyExc_TypeError, - "int expected instead of %s instance", - v->ob_type->tp_name); + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); return -1; } x = PyInt_AsUnsignedLongMask(v); @@ -365,10 +364,9 @@ static int get_ulong(PyObject *v, unsigned long *p) { unsigned long x; - if (!PyInt_Check(v) && !PyLong_Check(v)) { - PyErr_Format(PyExc_TypeError, - "int expected instead of %s instance", - v->ob_type->tp_name); + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); return -1; } x = PyInt_AsUnsignedLongMask(v); @@ -386,11 +384,10 @@ static int get_longlong(PyObject *v, PY_LONG_LONG *p) { PY_LONG_LONG x; - if (!PyInt_Check(v) && !PyLong_Check(v)) { - PyErr_Format(PyExc_TypeError, - "int expected instead of %s instance", - v->ob_type->tp_name); - return -1; + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); + return -1; } x = PyInt_AsUnsignedLongLongMask(v); if (x == -1 && PyErr_Occurred()) @@ -405,12 +402,11 @@ static int get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) { unsigned PY_LONG_LONG x; - if (!PyInt_Check(v) && !PyLong_Check(v)) { - PyErr_Format(PyExc_TypeError, - "int expected instead of %s instance", - v->ob_type->tp_name); - return -1; - } + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); + return -1; + } x = PyInt_AsUnsignedLongLongMask(v); if (x == -1 && PyErr_Occurred()) return -1; |