mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
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 <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
parent
cc79726d95
commit
4764e8b4c7
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,6 @@
|
||||
/* Ints */
|
||||
|
||||
#define PyInt_FromLong PyLong_FromLong
|
||||
#define PyInt_AsLong PyLong_AsLong
|
||||
|
||||
/* Module init */
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user