summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-10-23 19:24:22 (GMT)
committerGeorg Brandl <georg@python.org>2007-10-23 19:24:22 (GMT)
commite1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f (patch)
treeb189190df6a08b5249bef4e33385049f4ccf3d04 /Modules/_ctypes
parent083bea49a8b74a5f758c6641c299f0cc8c114616 (diff)
downloadcpython-e1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f.zip
cpython-e1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f.tar.gz
cpython-e1a0d11c5cceeb71b22f3e3148f8f7d6bc0b4d8f.tar.bz2
#1316: remove redundant PyLong_Check calls when PyInt_Check was already called.
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/_ctypes.c13
-rw-r--r--Modules/_ctypes/cfield.c10
2 files changed, 11 insertions, 12 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 22f2cb3..cca570a 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -236,7 +236,7 @@ static PyObject *
CDataType_from_address(PyObject *type, PyObject *value)
{
void *buf;
- if (!PyInt_Check(value) && !PyLong_Check(value)) {
+ if (!PyInt_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"integer expected");
return NULL;
@@ -265,7 +265,7 @@ CDataType_in_dll(PyObject *type, PyObject *args)
obj = PyObject_GetAttrString(dll, "_handle");
if (!obj)
return NULL;
- if (!PyInt_Check(obj) && !PyLong_Check(obj)) {
+ if (!PyInt_Check(obj)) {
PyErr_SetString(PyExc_TypeError,
"the _handle attribute of the second argument must be an integer");
Py_DECREF(obj);
@@ -1233,7 +1233,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
}
/* Should probably allow buffer interface as well */
/* int, long */
- if (PyInt_Check(value) || PyLong_Check(value)) {
+ if (PyInt_Check(value)) {
PyCArgObject *parg;
struct fielddesc *fd = getentry("P");
@@ -2697,7 +2697,7 @@ static int
_get_name(PyObject *obj, char **pname)
{
#ifdef MS_WIN32
- if (PyInt_Check(obj) || PyLong_Check(obj)) {
+ if (PyInt_Check(obj)) {
/* We have to use MAKEINTRESOURCEA for Windows CE.
Works on Windows as well, of course.
*/
@@ -2734,7 +2734,7 @@ CFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
obj = PyObject_GetAttrString(dll, "_handle");
if (!obj)
return NULL;
- if (!PyInt_Check(obj) && !PyLong_Check(obj)) {
+ if (!PyInt_Check(obj)) {
PyErr_SetString(PyExc_TypeError,
"the _handle attribute of the second argument must be an integer");
Py_DECREF(obj);
@@ -2859,8 +2859,7 @@ CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
#endif
if (1 == PyTuple_GET_SIZE(args)
- && (PyInt_Check(PyTuple_GET_ITEM(args, 0))
- || PyLong_Check(PyTuple_GET_ITEM(args, 0)))) {
+ && (PyInt_Check(PyTuple_GET_ITEM(args, 0)))) {
CDataObject *ob;
void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0));
if (ptr == NULL)
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index c36798a..534bb1e 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -329,7 +329,7 @@ static int
get_long(PyObject *v, long *p)
{
long x;
- if (!PyInt_Check(v) && !PyLong_Check(v)) {
+ if (!PyInt_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
@@ -348,7 +348,7 @@ static int
get_ulong(PyObject *v, unsigned long *p)
{
unsigned long x;
- if (!PyInt_Check(v) && !PyLong_Check(v)) {
+ if (!PyInt_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
@@ -369,7 +369,7 @@ static int
get_longlong(PyObject *v, PY_LONG_LONG *p)
{
PY_LONG_LONG x;
- if (!PyInt_Check(v) && !PyLong_Check(v)) {
+ if (!PyInt_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
@@ -388,7 +388,7 @@ static int
get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p)
{
unsigned PY_LONG_LONG x;
- if (!PyInt_Check(v) && !PyLong_Check(v)) {
+ if (!PyInt_Check(v)) {
PyErr_Format(PyExc_TypeError,
"int expected instead of %s instance",
v->ob_type->tp_name);
@@ -1373,7 +1373,7 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size)
assert(PyBytes_Check(str));
*(char **)ptr = PyBytes_AS_STRING(str);
return str;
- } else if (PyInt_Check(value) || PyLong_Check(value)) {
+ } else if (PyInt_Check(value)) {
#if SIZEOF_VOID_P == SIZEOF_LONG_LONG
*(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value);
#else