[2.7] bpo-34234: Use _PyAnyInt_Check() and _PyAnyInt_CheckExact(). (GH-8479)

diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 59d22e7..b21afb4 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -4504,7 +4504,7 @@
                 if (PyNumber_Check(v)) {
                     PyObject *iobj=NULL;
 
-                    if (PyInt_Check(v) || (PyLong_Check(v))) {
+                    if (_PyAnyInt_Check(v)) {
                         iobj = v;
                         Py_INCREF(iobj);
                     }