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

diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 8d36705..634c1b9 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4194,7 +4194,7 @@
                         "getaddrinfo() argument 1 must be string or None");
         return NULL;
     }
-    if (PyInt_Check(pobj) || PyLong_Check(pobj)) {
+    if (_PyAnyInt_Check(pobj)) {
         long value = PyLong_AsLong(pobj);
         if (value == -1 && PyErr_Occurred())
             return NULL;