From: Andrew Bartlett Date: Sat, 14 Mar 2020 21:32:11 +0000 (+1300) Subject: py3: Remove #define PyInt_AsLong PyLong_AsLong X-Git-Tag: ldb-2.2.0~1278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4764e8b4c7e459f6aa5861d26ffaec3a3026d77f;p=thirdparty%2Fsamba.git py3: Remove #define PyInt_AsLong PyLong_AsLong This allows us to end the use of Python 2/3 compatability macros. Signed-off-by: Andrew Bartlett Reviewed-by: Noel Power --- diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c index 7211d466a71..d00f3172f71 100644 --- a/lib/tdb/pytdb.c +++ b/lib/tdb/pytdb.c @@ -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; } diff --git a/libcli/nbt/pynbt.c b/libcli/nbt/pynbt.c index 1148da7289d..d9659e898d7 100644 --- a/libcli/nbt/pynbt.c +++ b/libcli/nbt/pynbt.c @@ -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; } diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 8eb50c8208b..93ab67f5f3c 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -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; } diff --git a/python/py3compat.h b/python/py3compat.h index 07a398de23b..ef20be18090 100644 --- a/python/py3compat.h +++ b/python/py3compat.h @@ -73,7 +73,6 @@ /* Ints */ #define PyInt_FromLong PyLong_FromLong -#define PyInt_AsLong PyLong_AsLong /* Module init */ diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c index b5156833df5..0525c44dfaf 100644 --- a/source3/passdb/py_passdb.c +++ b/source3/passdb/py_passdb.c @@ -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; iset_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); diff --git a/source4/lib/wmi/wmi.i b/source4/lib/wmi/wmi.i index b23ed6152cf..8f217e03fc8 100644 --- a/source4/lib/wmi/wmi.i +++ b/source4/lib/wmi/wmi.i @@ -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; diff --git a/source4/lib/wmi/wmi_wrap.c b/source4/lib/wmi/wmi_wrap.c index c44eeefccee..6732f4ed5cb 100644 --- a/source4/lib/wmi/wmi_wrap.c +++ b/source4/lib/wmi/wmi_wrap.c @@ -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; diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c index 33841ae0f11..be914ed5f14 100644 --- a/source4/librpc/rpc/pyrpc.c +++ b/source4/librpc/rpc/pyrpc.c @@ -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; }