py3: Remove #define PyInt_AsLong PyLong_AsLong
authorAndrew Bartlett <abartlet@samba.org>
Sat, 14 Mar 2020 21:32:11 +0000 (10:32 +1300)
committerNoel Power <npower@samba.org>
Mon, 23 Mar 2020 19:12:43 +0000 (19:12 +0000)
This allows us to end the use of Python 2/3 compatability macros.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
lib/tdb/pytdb.c
libcli/nbt/pynbt.c
pidl/lib/Parse/Pidl/Samba4/Python.pm
python/py3compat.h
source3/passdb/py_passdb.c
source4/lib/wmi/wmi.i
source4/lib/wmi/wmi_wrap.c
source4/librpc/rpc/pyrpc.c

index 7211d466a71495c7afb3d9164f9fb4f28728d570..d00f3172f719073eeb9bb5b5816b9318680480cc 100644 (file)
@@ -33,7 +33,6 @@
 
 #if PY_MAJOR_VERSION >= 3
 #define PyInt_FromLong PyLong_FromLong
-#define PyInt_AsLong PyLong_AsLong
 #define Py_TPFLAGS_HAVE_ITER 0
 #endif
 
@@ -556,7 +555,7 @@ static int obj_set_max_dead(PyTdbObject *self, PyObject *max_dead, void *closure
        PyErr_TDB_RAISE_RETURN_MINUS_1_IF_CLOSED(self);
        if (!PyLong_Check(max_dead))
                return -1;
-       tdb_set_max_dead(self->ctx, PyInt_AsLong(max_dead));
+       tdb_set_max_dead(self->ctx, PyLong_AsLong(max_dead));
        return 0;
 }
 
index 1148da7289dbf0cb60dfe823126292da25cbdc06..d9659e898d73fd1815fa977e2f9420875a295992 100644 (file)
@@ -80,7 +80,7 @@ static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, u
                        *dest_port = NBT_NAME_SERVICE_PORT;
                        return true;
                } else if (PyLong_Check(PyTuple_GetItem(obj, 1))) {
-                       *dest_port = PyInt_AsLong(PyTuple_GetItem(obj, 1));
+                       *dest_port = PyLong_AsLong(PyTuple_GetItem(obj, 1));
                        return true;
                } else {
                        PyErr_SetString(PyExc_TypeError, "Destination tuple second element not a port");
@@ -100,7 +100,7 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
                        if (name->name == NULL) {
                                goto err;
                        }
-                       name->type = PyInt_AsLong(PyTuple_GetItem(obj, 1));
+                       name->type = PyLong_AsLong(PyTuple_GetItem(obj, 1));
                        if (name->type == -1 && PyErr_Occurred()) {
                                goto err;
                        }
@@ -115,7 +115,7 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
                        if (name->scope == NULL) {
                                goto err;
                        }
-                       name->type = PyInt_AsLong(PyTuple_GetItem(obj, 2));
+                       name->type = PyLong_AsLong(PyTuple_GetItem(obj, 2));
                        if (name->type == -1 && PyErr_Occurred()) {
                                goto err;
                        }
index 8eb50c8208b095411b4bd56f61bd606078b7f7d5..93ab67f5f3c007763b9ed95dcd4cfd4b550c6f16 100644 (file)
@@ -1856,17 +1856,17 @@ sub ConvertObjectFromPythonData($$$$$$;$$)
        }
 
        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "NTSTATUS") {
-               $self->pidl("$target = NT_STATUS(PyInt_AsLong($cvar));");
+               $self->pidl("$target = NT_STATUS(PyLong_AsLong($cvar));");
                return;
        }
 
        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "WERROR") {
-               $self->pidl("$target = W_ERROR(PyInt_AsLong($cvar));");
+               $self->pidl("$target = W_ERROR(PyLong_AsLong($cvar));");
                return;
        }
 
        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "HRESULT") {
-               $self->pidl("$target = HRES_ERROR(PyInt_AsLong($cvar));");
+               $self->pidl("$target = HRES_ERROR(PyLong_AsLong($cvar));");
                return;
        }
 
index 07a398de23b9c602c3637203c7cf017375df5a05..ef20be18090cea2f72a25458b5a48d0e008fbb25 100644 (file)
@@ -73,7 +73,6 @@
 /* Ints */
 
 #define PyInt_FromLong PyLong_FromLong
-#define PyInt_AsLong PyLong_AsLong
 
 /* Module init */
 
index b5156833df537f4f21e914a149239bbb4ceecdd0..0525c44dfaf87ede56d0094d592022b1eb665daa 100644 (file)
@@ -73,7 +73,7 @@ static int py_samu_set_logon_time(PyObject *obj, PyObject *value, void *closure)
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_logon_time(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_logon_time(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -98,7 +98,7 @@ static int py_samu_set_logoff_time(PyObject *obj, PyObject *value, void *closure
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_logoff_time(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_logoff_time(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -123,7 +123,7 @@ static int py_samu_set_kickoff_time(PyObject *obj, PyObject *value, void *closur
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_kickoff_time(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_kickoff_time(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -148,7 +148,7 @@ static int py_samu_set_bad_password_time(PyObject *obj, PyObject *value, void *c
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_bad_password_time(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_bad_password_time(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -173,7 +173,7 @@ static int py_samu_set_pass_last_set_time(PyObject *obj, PyObject *value, void *
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_pass_last_set_time(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_pass_last_set_time(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -198,7 +198,7 @@ static int py_samu_set_pass_can_change_time(PyObject *obj, PyObject *value, void
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_pass_can_change_time(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_pass_can_change_time(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -830,7 +830,7 @@ static int py_samu_set_acct_ctrl(PyObject *obj, PyObject *value, void *closure)
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_acct_ctrl(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_acct_ctrl(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -855,7 +855,7 @@ static int py_samu_set_logon_divs(PyObject *obj, PyObject *value, void *closure)
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_logon_divs(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_logon_divs(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -880,7 +880,7 @@ static int py_samu_set_hours_len(PyObject *obj, PyObject *value, void *closure)
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_hours_len(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_hours_len(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -937,7 +937,7 @@ static int py_samu_set_hours(PyObject *obj, PyObject *value, void *closure)
 
        for (i=0; i < hours_len; i++) {
                PY_CHECK_TYPE(&PyLong_Type, PyList_GET_ITEM(value,i), return -1;);
-               hours[i] = PyInt_AsLong(PyList_GET_ITEM(value, i));
+               hours[i] = PyLong_AsLong(PyList_GET_ITEM(value, i));
        }
 
        status = pdb_set_hours(sam_acct, hours, hours_len, PDB_CHANGED);
@@ -968,7 +968,7 @@ static int py_samu_set_bad_password_count(PyObject *obj, PyObject *value, void *
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_bad_password_count(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_bad_password_count(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -993,7 +993,7 @@ static int py_samu_set_logon_count(PyObject *obj, PyObject *value, void *closure
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_logon_count(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_logon_count(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -1018,7 +1018,7 @@ static int py_samu_set_country_code(PyObject *obj, PyObject *value, void *closur
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_country_code(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_country_code(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -1043,7 +1043,7 @@ static int py_samu_set_code_page(PyObject *obj, PyObject *value, void *closure)
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       if (!pdb_set_code_page(sam_acct, PyInt_AsLong(value), PDB_CHANGED)) {
+       if (!pdb_set_code_page(sam_acct, PyLong_AsLong(value), PDB_CHANGED)) {
                talloc_free(frame);
                return -1;
        }
@@ -1268,7 +1268,7 @@ static int py_groupmap_set_gid(PyObject *obj, PyObject *value, void *closure)
        GROUP_MAP *group_map = (GROUP_MAP *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       group_map->gid = PyInt_AsLong(value);
+       group_map->gid = PyLong_AsLong(value);
        talloc_free(frame);
        return 0;
 }
@@ -1332,7 +1332,7 @@ static int py_groupmap_set_sid_name_use(PyObject *obj, PyObject *value, void *cl
        GROUP_MAP *group_map = (GROUP_MAP *)pytalloc_get_ptr(obj);
 
        PY_CHECK_TYPE(&PyLong_Type, value, return -1;);
-       group_map->sid_name_use = PyInt_AsLong(value);
+       group_map->sid_name_use = PyLong_AsLong(value);
        talloc_free(frame);
        return 0;
 }
@@ -2652,7 +2652,7 @@ static PyObject *py_pdb_set_account_policy(PyObject *self, PyObject *args)
        for (i=0; i<count; i++) {
                if ((py_value = PyDict_GetItemString(py_acct_policy, names[i])) != NULL) {
                        type = account_policy_name_to_typenum(names[i]);
-                       status = methods->set_account_policy(methods, type, PyInt_AsLong(py_value));
+                       status = methods->set_account_policy(methods, type, PyLong_AsLong(py_value));
                        if (!NT_STATUS_IS_OK(status)) {
                                PyErr_Format(py_pdb_error, "Error setting account policy (%s), (%d,%s)",
                                                names[i],
@@ -3320,13 +3320,13 @@ static PyObject *py_pdb_set_trusted_domain(PyObject *self, PyObject *args)
        td_info.trust_auth_outgoing.length = len;
 
        py_tmp = PyDict_GetItemString(py_td_info, "trust_direction");
-       td_info.trust_direction = PyInt_AsLong(py_tmp);
+       td_info.trust_direction = PyLong_AsLong(py_tmp);
 
        py_tmp = PyDict_GetItemString(py_td_info, "trust_type");
-       td_info.trust_type = PyInt_AsLong(py_tmp);
+       td_info.trust_type = PyLong_AsLong(py_tmp);
 
        py_tmp = PyDict_GetItemString(py_td_info, "trust_attributes");
-       td_info.trust_attributes = PyInt_AsLong(py_tmp);
+       td_info.trust_attributes = PyLong_AsLong(py_tmp);
 
        py_tmp = PyDict_GetItemString(py_td_info, "trust_forest_trust_info");
        PyBytes_AsStringAndSize(py_tmp, (char **)&td_info.trust_forest_trust_info.data, &len);
index b23ed6152cf39f6de994222b4ed084638cca3a73..8f217e03fc8ca78bf98f78e66a313b0a2e705a0d 100644 (file)
@@ -303,7 +303,7 @@ typedef struct IEnumWbemClassObject {
         if (PyLong_Check($input))
                $1 = PyLong_AsUnsignedLong($input);
         else if (PyLong_Check($input))
-               $1 = PyInt_AsLong($input);
+               $1 = PyLong_AsLong($input);
         else {
             PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
             return NULL;
index c44eeefccee57086710d0a6c15066fd453da8c45..6732f4ed5cbd7c2fce1b422a8514224630bb512e 100644 (file)
@@ -2671,7 +2671,7 @@ SWIG_AsVal_double (PyObject *obj, double *val)
     if (val) *val = PyFloat_AsDouble(obj);
     return SWIG_OK;
   } else if (PyLong_Check(obj)) {
-    if (val) *val = PyInt_AsLong(obj);
+    if (val) *val = PyLong_AsLong(obj);
     return SWIG_OK;
   } else if (PyLong_Check(obj)) {
     double v = PyLong_AsDouble(obj);
@@ -2747,7 +2747,7 @@ SWIGINTERN int
 SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) 
 {
   if (PyLong_Check(obj)) {
-    long v = PyInt_AsLong(obj);
+    long v = PyLong_AsLong(obj);
     if (v >= 0) {
       if (val) *val = v;
       return SWIG_OK;
@@ -2825,7 +2825,7 @@ SWIGINTERN int
 SWIG_AsVal_long (PyObject *obj, long* val)
 {
   if (PyLong_Check(obj)) {
-    if (val) *val = PyInt_AsLong(obj);
+    if (val) *val = PyLong_AsLong(obj);
     return SWIG_OK;
   } else if (PyLong_Check(obj)) {
     long v = PyLong_AsLong(obj);
@@ -2839,7 +2839,7 @@ SWIG_AsVal_long (PyObject *obj, long* val)
 #ifdef SWIG_PYTHON_CAST_MODE
   {
     int dispatch = 0;
-    long v = PyInt_AsLong(obj);
+    long v = PyLong_AsLong(obj);
     if (!PyErr_Occurred()) {
       if (val) *val = v;
       return SWIG_AddCast(SWIG_OK);
@@ -3608,7 +3608,7 @@ SWIGINTERN PyObject *_wrap_IEnumWbemClassObject_SmartNext(PyObject *SWIGUNUSEDPA
     if (PyLong_Check(obj2))
     arg4 = PyLong_AsUnsignedLong(obj2);
     else if (PyLong_Check(obj2))
-    arg4 = PyInt_AsLong(obj2);
+    arg4 = PyLong_AsLong(obj2);
     else {
       PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
       return NULL;
index 33841ae0f119777bc755a0b2511f596919f40e32..be914ed5f14be3402acf0645a936bbf4b72e0381 100644 (file)
@@ -78,7 +78,7 @@ static bool ndr_syntax_from_py_object(PyObject *object, struct ndr_syntax_id *sy
                        return false;
                }
 
-               syntax_id->if_version = PyInt_AsLong(item);
+               syntax_id->if_version = PyLong_AsLong(item);
                return true;
        }