| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,9 @@ PyAPI_DATA(PyTypeObject) PyInt_Type; | |||
| 31 | 31 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_INT_SUBCLASS) | |
| 32 | 32 | #define PyInt_CheckExact(op) (Py_TYPE(op) == &PyInt_Type) | |
| 33 | 33 | ||
| 34 | + #define _PyAnyInt_Check(op) (PyInt_Check(op) || PyLong_Check(op)) | ||
| 35 | + #define _PyAnyInt_CheckExact(op) (PyInt_CheckExact(op) || PyLong_CheckExact(op)) | ||
| 36 | + | ||
| 34 | 37 | PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); | |
| 35 | 38 | #ifdef Py_USING_UNICODE | |
| 36 | 39 | PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -224,7 +224,7 @@ _set_int(const char *name, int *target, PyObject *src, int dflt) | |||
| 224 | 224 | if (src == NULL) | |
| 225 | 225 | *target = dflt; | |
| 226 | 226 | else { | |
| 227 | - if (!PyInt_Check(src) && !PyLong_Check(src)) { | ||
| 227 | + if (!_PyAnyInt_Check(src)) { | ||
| 228 | 228 | PyErr_Format(PyExc_TypeError, | |
| 229 | 229 | "\"%s\" must be an integer", name); | |
| 230 | 230 | return -1; | |
@@ -1452,7 +1452,7 @@ csv_field_size_limit(PyObject *module, PyObject *args) | |||
| 1452 | 1452 | if (!PyArg_UnpackTuple(args, "field_size_limit", 0, 1, &new_limit)) | |
| 1453 | 1453 | return NULL; | |
| 1454 | 1454 | if (new_limit != NULL) { | |
| 1455 | - if (!PyInt_Check(new_limit) && !PyLong_Check(new_limit)) { | ||
| 1455 | + if (!_PyAnyInt_Check(new_limit)) { | ||
| 1456 | 1456 | PyErr_Format(PyExc_TypeError, | |
| 1457 | 1457 | "limit must be an integer"); | |
| 1458 | 1458 | return NULL; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -547,7 +547,7 @@ static PyObject * | |||
| 547 | 547 | CDataType_from_address(PyObject *type, PyObject *value) | |
| 548 | 548 | { | |
| 549 | 549 | void *buf; | |
| 550 | - if (!PyInt_Check(value) && !PyLong_Check(value)) { | ||
| 550 | + if (!_PyAnyInt_Check(value)) { | ||
| 551 | 551 | PyErr_SetString(PyExc_TypeError, | |
| 552 | 552 | "integer expected"); | |
| 553 | 553 | return NULL; | |
@@ -691,7 +691,7 @@ CDataType_in_dll(PyObject *type, PyObject *args) | |||
| 691 | 691 | obj = PyObject_GetAttrString(dll, "_handle"); | |
| 692 | 692 | if (!obj) | |
| 693 | 693 | return NULL; | |
| 694 | - if (!PyInt_Check(obj) && !PyLong_Check(obj)) { | ||
| 694 | + if (!_PyAnyInt_Check(obj)) { | ||
| 695 | 695 | PyErr_SetString(PyExc_TypeError, | |
| 696 | 696 | "the _handle attribute of the second argument must be an integer"); | |
| 697 | 697 | Py_DECREF(obj); | |
@@ -1779,7 +1779,7 @@ c_void_p_from_param(PyObject *type, PyObject *value) | |||
| 1779 | 1779 | } | |
| 1780 | 1780 | /* Should probably allow buffer interface as well */ | |
| 1781 | 1781 | /* int, long */ | |
| 1782 | - if (PyInt_Check(value) || PyLong_Check(value)) { | ||
| 1782 | + if (_PyAnyInt_Check(value)) { | ||
| 1783 | 1783 | PyCArgObject *parg; | |
| 1784 | 1784 | struct fielddesc *fd = _ctypes_get_fielddesc("P"); | |
| 1785 | 1785 | ||
@@ -3419,7 +3419,7 @@ static int | |||
| 3419 | 3419 | _get_name(PyObject *obj, char **pname) | |
| 3420 | 3420 | { | |
| 3421 | 3421 | #ifdef MS_WIN32 | |
| 3422 | - if (PyInt_Check(obj) || PyLong_Check(obj)) { | ||
| 3422 | + if (_PyAnyInt_Check(obj)) { | ||
| 3423 | 3423 | /* We have to use MAKEINTRESOURCEA for Windows CE. | |
| 3424 | 3424 | Works on Windows as well, of course. | |
| 3425 | 3425 | */ | |
@@ -3469,7 +3469,7 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds) | |||
| 3469 | 3469 | Py_DECREF(ftuple); | |
| 3470 | 3470 | return NULL; | |
| 3471 | 3471 | } | |
| 3472 | - if (!PyInt_Check(obj) && !PyLong_Check(obj)) { | ||
| 3472 | + if (!_PyAnyInt_Check(obj)) { | ||
| 3473 | 3473 | PyErr_SetString(PyExc_TypeError, | |
| 3474 | 3474 | "the _handle attribute of the second argument must be an integer"); | |
| 3475 | 3475 | Py_DECREF(ftuple); | |
@@ -3600,8 +3600,7 @@ PyCFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |||
| 3600 | 3600 | #endif | |
| 3601 | 3601 | ||
| 3602 | 3602 | 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))) { | ||
| 3605 | 3604 | CDataObject *ob; | |
| 3606 | 3605 | void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0)); | |
| 3607 | 3606 | if (ptr == NULL && PyErr_Occurred()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1361,7 +1361,7 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size) | |||
| 1361 | 1361 | return NULL; | |
| 1362 | 1362 | *(char **)ptr = PyString_AS_STRING(str); | |
| 1363 | 1363 | return str; | |
| 1364 | - } else if (PyInt_Check(value) || PyLong_Check(value)) { | ||
| 1364 | + } else if (_PyAnyInt_Check(value)) { | ||
| 1365 | 1365 | #if SIZEOF_VOID_P == SIZEOF_LONG_LONG | |
| 1366 | 1366 | *(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value); | |
| 1367 | 1367 | #else | |
@@ -1410,7 +1410,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size) | |||
| 1410 | 1410 | _ctypes_conversion_errors); | |
| 1411 | 1411 | if (!value) | |
| 1412 | 1412 | return NULL; | |
| 1413 | - } else if (PyInt_Check(value) || PyLong_Check(value)) { | ||
| 1413 | + } else if (_PyAnyInt_Check(value)) { | ||
| 1414 | 1414 | #if SIZEOF_VOID_P == SIZEOF_LONG_LONG | |
| 1415 | 1415 | *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongLongMask(value); | |
| 1416 | 1416 | #else | |
@@ -1565,7 +1565,7 @@ P_set(void *ptr, PyObject *value, Py_ssize_t size) | |||
| 1565 | 1565 | _RET(value); | |
| 1566 | 1566 | } | |
| 1567 | 1567 | ||
| 1568 | - if (!PyInt_Check(value) && !PyLong_Check(value)) { | ||
| 1568 | + if (!_PyAnyInt_Check(value)) { | ||
| 1569 | 1569 | PyErr_SetString(PyExc_TypeError, | |
| 1570 | 1570 | "cannot be converted to pointer"); | |
| 1571 | 1571 | return NULL; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -194,7 +194,7 @@ PyCursesCheckERR(int code, char *fname) | |||
| 194 | 194 | static int | |
| 195 | 195 | PyCurses_ConvertToChtype(PyObject *obj, chtype *ch) | |
| 196 | 196 | { | |
| 197 | - if (PyInt_Check(obj) || PyLong_Check(obj)) { | ||
| 197 | + if (_PyAnyInt_Check(obj)) { | ||
| 198 | 198 | *ch = (chtype) PyInt_AsLong(obj); | |
| 199 | 199 | if (*ch == (chtype) -1 && PyErr_Occurred()) | |
| 200 | 200 | return 0; | |
@@ -2603,7 +2603,7 @@ PyCurses_UnCtrl(PyObject *self, PyObject *args) | |||
| 2603 | 2603 | ||
| 2604 | 2604 | if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL; | |
| 2605 | 2605 | ||
| 2606 | - if (PyInt_Check(temp) || PyLong_Check(temp)) { | ||
| 2606 | + if (_PyAnyInt_Check(temp)) { | ||
| 2607 | 2607 | ch = (chtype) PyInt_AsLong(temp); | |
| 2608 | 2608 | if (ch == (chtype) -1 && PyErr_Occurred()) | |
| 2609 | 2609 | return NULL; | |
@@ -2628,7 +2628,7 @@ PyCurses_UngetCh(PyObject *self, PyObject *args) | |||
| 2628 | 2628 | ||
| 2629 | 2629 | if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL; | |
| 2630 | 2630 | ||
| 2631 | - if (PyInt_Check(temp) || PyLong_Check(temp)) { | ||
| 2631 | + if (_PyAnyInt_Check(temp)) { | ||
| 2632 | 2632 | ch = (int) PyInt_AsLong(temp); | |
| 2633 | 2633 | if (ch == -1 && PyErr_Occurred()) | |
| 2634 | 2634 | return NULL; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1347,7 +1347,7 @@ element_subscr(PyObject* self_, PyObject* item) | |||
| 1347 | 1347 | ElementObject* self = (ElementObject*) self_; | |
| 1348 | 1348 | ||
| 1349 | 1349 | #if (PY_VERSION_HEX < 0x02050000) | |
| 1350 | - if (PyInt_Check(item) || PyLong_Check(item)) { | ||
| 1350 | + if (_PyAnyInt_Check(item)) { | ||
| 1351 | 1351 | long i = PyInt_AsLong(item); | |
| 1352 | 1352 | #else | |
| 1353 | 1353 | if (PyIndex_Check(item)) { | |
@@ -1404,7 +1404,7 @@ element_ass_subscr(PyObject* self_, PyObject* item, PyObject* value) | |||
| 1404 | 1404 | ElementObject* self = (ElementObject*) self_; | |
| 1405 | 1405 | ||
| 1406 | 1406 | #if (PY_VERSION_HEX < 0x02050000) | |
| 1407 | - if (PyInt_Check(item) || PyLong_Check(item)) { | ||
| 1407 | + if (_PyAnyInt_Check(item)) { | ||
| 1408 | 1408 | long i = PyInt_AsLong(item); | |
| 1409 | 1409 | #else | |
| 1410 | 1410 | if (PyIndex_Check(item)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1981,7 +1981,7 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi | |||
| 1981 | 1981 | return -1; | |
| 1982 | 1982 | return _steal_list_append(rval, encoded); | |
| 1983 | 1983 | } | |
| 1984 | - else if (PyInt_Check(obj) || PyLong_Check(obj)) { | ||
| 1984 | + else if (_PyAnyInt_Check(obj)) { | ||
| 1985 | 1985 | PyObject *encoded = PyObject_Str(obj); | |
| 1986 | 1986 | if (encoded == NULL) | |
| 1987 | 1987 | return -1; | |
@@ -2131,7 +2131,7 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss | |||
| 2131 | 2131 | if (kstr == NULL) | |
| 2132 | 2132 | goto bail; | |
| 2133 | 2133 | } | |
| 2134 | - else if (PyInt_Check(key) || PyLong_Check(key)) { | ||
| 2134 | + else if (_PyAnyInt_Check(key)) { | ||
| 2135 | 2135 | kstr = PyObject_Str(key); | |
| 2136 | 2136 | if (kstr == NULL) | |
| 2137 | 2137 | goto bail; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -415,7 +415,7 @@ random_jumpahead(RandomObject *self, PyObject *n) | |||
| 415 | 415 | PyObject *remobj; | |
| 416 | 416 | unsigned long *mt, tmp, nonzero; | |
| 417 | 417 | ||
| 418 | - if (!PyInt_Check(n) && !PyLong_Check(n)) { | ||
| 418 | + if (!_PyAnyInt_Check(n)) { | ||
| 419 | 419 | PyErr_Format(PyExc_TypeError, "jumpahead requires an " | |
| 420 | 420 | "integer, not '%s'", | |
| 421 | 421 | Py_TYPE(n)->tp_name); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,7 +205,7 @@ static int _need_adapt(PyObject* obj) | |||
| 205 | 205 | return 1; | |
| 206 | 206 | } | |
| 207 | 207 | ||
| 208 | - if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj) | ||
| 208 | + if (_PyAnyInt_CheckExact(obj) | ||
| 209 | 209 | || PyFloat_CheckExact(obj) || PyString_CheckExact(obj) | |
| 210 | 210 | || PyUnicode_CheckExact(obj) || PyBuffer_Check(obj)) { | |
| 211 | 211 | return 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3327,15 +3327,15 @@ match_getindex(MatchObject* self, PyObject* index) | |||
| 3327 | 3327 | { | |
| 3328 | 3328 | Py_ssize_t i; | |
| 3329 | 3329 | ||
| 3330 | - if (PyInt_Check(index) || PyLong_Check(index)) | ||
| 3330 | + if (_PyAnyInt_Check(index)) | ||
| 3331 | 3331 | return PyInt_AsSsize_t(index); | |
| 3332 | 3332 | ||
| 3333 | 3333 | i = -1; | |
| 3334 | 3334 | ||
| 3335 | 3335 | if (self->pattern->groupindex) { | |
| 3336 | 3336 | index = PyObject_GetItem(self->pattern->groupindex, index); | |
| 3337 | 3337 | if (index) { | |
| 3338 | - if (PyInt_Check(index) || PyLong_Check(index)) | ||
| 3338 | + if (_PyAnyInt_Check(index)) | ||
| 3339 | 3339 | i = PyInt_AsSsize_t(index); | |
| 3340 | 3340 | Py_DECREF(index); | |
| 3341 | 3341 | } else | |
| Back | FazBrowse Home | New Git URL |
0 commit comments