[2.7] bpo-34234: Use _PyAnyInt_Check() and _PyAnyInt_CheckExact(). (G… · python/cpython@48c8bf2

@@ -547,7 +547,7 @@ static PyObject *

547547

CDataType_from_address(PyObject *type, PyObject *value)

548548

{

549549

void *buf;

550-

if (!PyInt_Check(value) && !PyLong_Check(value)) {

550+

if (!_PyAnyInt_Check(value)) {

551551

PyErr_SetString(PyExc_TypeError,

552552

"integer expected");

553553

return NULL;

@@ -691,7 +691,7 @@ CDataType_in_dll(PyObject *type, PyObject *args)

691691

obj = PyObject_GetAttrString(dll, "_handle");

692692

if (!obj)

693693

return NULL;

694-

if (!PyInt_Check(obj) && !PyLong_Check(obj)) {

694+

if (!_PyAnyInt_Check(obj)) {

695695

PyErr_SetString(PyExc_TypeError,

696696

"the _handle attribute of the second argument must be an integer");

697697

Py_DECREF(obj);

@@ -1779,7 +1779,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)

17791779

}

17801780

/* Should probably allow buffer interface as well */

17811781

/* int, long */

1782-

if (PyInt_Check(value) || PyLong_Check(value)) {

1782+

if (_PyAnyInt_Check(value)) {

17831783

PyCArgObject *parg;

17841784

struct fielddesc *fd = _ctypes_get_fielddesc("P");

17851785

@@ -3419,7 +3419,7 @@ static int

34193419

_get_name(PyObject *obj, char **pname)

34203420

{

34213421

#ifdef MS_WIN32

3422-

if (PyInt_Check(obj) || PyLong_Check(obj)) {

3422+

if (_PyAnyInt_Check(obj)) {

34233423

/* We have to use MAKEINTRESOURCEA for Windows CE.

34243424

Works on Windows as well, of course.

34253425

*/

@@ -3469,7 +3469,7 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)

34693469

Py_DECREF(ftuple);

34703470

return NULL;

34713471

}

3472-

if (!PyInt_Check(obj) && !PyLong_Check(obj)) {

3472+

if (!_PyAnyInt_Check(obj)) {

34733473

PyErr_SetString(PyExc_TypeError,

34743474

"the _handle attribute of the second argument must be an integer");

34753475

Py_DECREF(ftuple);

@@ -3600,8 +3600,7 @@ PyCFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)

36003600

#endif

3601360136023602

if (1 == PyTuple_GET_SIZE(args)

3603-

&& (PyInt_Check(PyTuple_GET_ITEM(args, 0))

3604-

|| PyLong_Check(PyTuple_GET_ITEM(args, 0)))) {

3603+

&& _PyAnyInt_Check(PyTuple_GET_ITEM(args, 0))) {

36053604

CDataObject *ob;

36063605

void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0));

36073606

if (ptr == NULL && PyErr_Occurred())