mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
py3: Remove PyStr_AsString() compatability macro
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard function names. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com>
This commit is contained in:
parent
d9d9463fd3
commit
f178daa854
@ -58,7 +58,7 @@ static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject *
|
||||
static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, uint16_t *dest_port)
|
||||
{
|
||||
if (PyUnicode_Check(obj) || PyUnicode_Check(obj)) {
|
||||
*dest_addr = PyStr_AsString(obj);
|
||||
*dest_addr = PyUnicode_AsUTF8(obj);
|
||||
*dest_port = NBT_NAME_SERVICE_PORT;
|
||||
return true;
|
||||
}
|
||||
@ -74,7 +74,7 @@ static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, u
|
||||
return false;
|
||||
}
|
||||
|
||||
*dest_addr = PyStr_AsString(obj);
|
||||
*dest_addr = PyUnicode_AsUTF8(obj);
|
||||
|
||||
if (PyTuple_Size(obj) == 1) {
|
||||
*dest_port = NBT_NAME_SERVICE_PORT;
|
||||
@ -96,7 +96,7 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
|
||||
{
|
||||
if (PyTuple_Check(obj)) {
|
||||
if (PyTuple_Size(obj) == 2) {
|
||||
name->name = PyStr_AsString(PyTuple_GetItem(obj, 0));
|
||||
name->name = PyUnicode_AsUTF8(PyTuple_GetItem(obj, 0));
|
||||
if (name->name == NULL) {
|
||||
goto err;
|
||||
}
|
||||
@ -107,11 +107,11 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
|
||||
name->scope = NULL;
|
||||
return true;
|
||||
} else if (PyTuple_Size(obj) == 3) {
|
||||
name->name = PyStr_AsString(PyTuple_GetItem(obj, 0));
|
||||
name->name = PyUnicode_AsUTF8(PyTuple_GetItem(obj, 0));
|
||||
if (name->name == NULL) {
|
||||
goto err;
|
||||
}
|
||||
name->scope = PyStr_AsString(PyTuple_GetItem(obj, 1));
|
||||
name->scope = PyUnicode_AsUTF8(PyTuple_GetItem(obj, 1));
|
||||
if (name->scope == NULL) {
|
||||
goto err;
|
||||
}
|
||||
@ -128,7 +128,7 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
|
||||
|
||||
if (PyUnicode_Check(obj) || PyUnicode_Check(obj)) {
|
||||
/* FIXME: Parse string to be able to interpret things like RHONWYN<02> ? */
|
||||
name->name = PyStr_AsString(obj);
|
||||
name->name = PyUnicode_AsUTF8(obj);
|
||||
if (name->name == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
@ -54,8 +54,6 @@
|
||||
|
||||
/* Strings */
|
||||
|
||||
#define PyStr_AsString PyUnicode_AsUTF8
|
||||
|
||||
#define PyStr_AsUTF8 PyUnicode_AsUTF8
|
||||
#define PyStr_AsUTF8AndSize PyUnicode_AsUTF8AndSize
|
||||
|
||||
|
@ -250,7 +250,7 @@ static int py_samu_set_username(PyObject *obj, PyObject *value, void *closure)
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_username(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_username(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -281,7 +281,7 @@ static int py_samu_set_domain(PyObject *obj, PyObject *value, void *closure)
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_domain(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_domain(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -312,7 +312,7 @@ static int py_samu_set_nt_username(PyObject *obj, PyObject *value, void *closure
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_nt_username(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_nt_username(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -343,7 +343,7 @@ static int py_samu_set_full_name(PyObject *obj, PyObject *value, void *closure)
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_fullname(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_fullname(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -374,7 +374,7 @@ static int py_samu_set_home_dir(PyObject *obj, PyObject *value, void *closure)
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_homedir(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_homedir(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -405,7 +405,7 @@ static int py_samu_set_dir_drive(PyObject *obj, PyObject *value, void *closure)
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_dir_drive(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_dir_drive(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -436,7 +436,7 @@ static int py_samu_set_logon_script(PyObject *obj, PyObject *value, void *closur
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_logon_script(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_logon_script(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -467,7 +467,7 @@ static int py_samu_set_profile_path(PyObject *obj, PyObject *value, void *closur
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_profile_path(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_profile_path(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -498,7 +498,7 @@ static int py_samu_set_acct_desc(PyObject *obj, PyObject *value, void *closure)
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_acct_desc(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_acct_desc(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -529,7 +529,7 @@ static int py_samu_set_workstations(PyObject *obj, PyObject *value, void *closur
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_workstations(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_workstations(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -560,7 +560,7 @@ static int py_samu_set_comment(PyObject *obj, PyObject *value, void *closure)
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_comment(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_comment(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -591,7 +591,7 @@ static int py_samu_set_munged_dial(PyObject *obj, PyObject *value, void *closure
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
PY_CHECK_TYPE(&PyUnicode_Type, value, return -1;);
|
||||
if (!pdb_set_munged_dial(sam_acct, PyStr_AsString(value), PDB_CHANGED)) {
|
||||
if (!pdb_set_munged_dial(sam_acct, PyUnicode_AsUTF8(value), PDB_CHANGED)) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -805,7 +805,7 @@ static int py_samu_set_plaintext_passwd(PyObject *obj, PyObject *value, void *cl
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
|
||||
|
||||
if (!pdb_set_plaintext_passwd(sam_acct, PyStr_AsString(value))) {
|
||||
if (!pdb_set_plaintext_passwd(sam_acct, PyUnicode_AsUTF8(value))) {
|
||||
talloc_free(frame);
|
||||
return -1;
|
||||
}
|
||||
@ -1361,7 +1361,7 @@ static int py_groupmap_set_nt_name(PyObject *obj, PyObject *value, void *closure
|
||||
if (value == Py_None) {
|
||||
fstrcpy(group_map->nt_name, NULL);
|
||||
} else {
|
||||
fstrcpy(group_map->nt_name, PyStr_AsString(value));
|
||||
fstrcpy(group_map->nt_name, PyUnicode_AsUTF8(value));
|
||||
}
|
||||
talloc_free(frame);
|
||||
return 0;
|
||||
@ -1391,7 +1391,7 @@ static int py_groupmap_set_comment(PyObject *obj, PyObject *value, void *closure
|
||||
if (value == Py_None) {
|
||||
fstrcpy(group_map->comment, NULL);
|
||||
} else {
|
||||
fstrcpy(group_map->comment, PyStr_AsString(value));
|
||||
fstrcpy(group_map->comment, PyUnicode_AsUTF8(value));
|
||||
}
|
||||
talloc_free(frame);
|
||||
return 0;
|
||||
@ -2430,13 +2430,13 @@ static PyObject *py_pdb_set_aliasinfo(PyObject *self, PyObject *args)
|
||||
|
||||
alias_sid = pytalloc_get_ptr(py_alias_sid);
|
||||
|
||||
alias_info.acct_name = talloc_strdup(frame, PyStr_AsString(PyDict_GetItemString(py_alias_info, "acct_name")));
|
||||
alias_info.acct_name = talloc_strdup(frame, PyUnicode_AsUTF8(PyDict_GetItemString(py_alias_info, "acct_name")));
|
||||
if (alias_info.acct_name == NULL) {
|
||||
PyErr_Format(py_pdb_error, "Unable to allocate memory");
|
||||
talloc_free(frame);
|
||||
return NULL;
|
||||
}
|
||||
alias_info.acct_desc = talloc_strdup(frame, PyStr_AsString(PyDict_GetItemString(py_alias_info, "acct_desc")));
|
||||
alias_info.acct_desc = talloc_strdup(frame, PyUnicode_AsUTF8(PyDict_GetItemString(py_alias_info, "acct_desc")));
|
||||
if (alias_info.acct_desc == NULL) {
|
||||
PyErr_Format(py_pdb_error, "Unable to allocate memory");
|
||||
talloc_free(frame);
|
||||
@ -3303,10 +3303,10 @@ static PyObject *py_pdb_set_trusted_domain(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
py_tmp = PyDict_GetItemString(py_td_info, "domain_name");
|
||||
td_info.domain_name = discard_const_p(char, PyStr_AsString(py_tmp));
|
||||
td_info.domain_name = discard_const_p(char, PyUnicode_AsUTF8(py_tmp));
|
||||
|
||||
py_tmp = PyDict_GetItemString(py_td_info, "netbios_name");
|
||||
td_info.netbios_name = discard_const_p(char, PyStr_AsString(py_tmp));
|
||||
td_info.netbios_name = discard_const_p(char, PyUnicode_AsUTF8(py_tmp));
|
||||
|
||||
py_tmp = PyDict_GetItemString(py_td_info, "security_identifier");
|
||||
td_info.security_identifier = *pytalloc_get_type(py_tmp, struct dom_sid);
|
||||
|
@ -73,7 +73,7 @@ static struct gensec_settings *settings_from_object(TALLOC_CTX *mem_ctx, PyObjec
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s->target_hostname = PyStr_AsString(py_hostname);
|
||||
s->target_hostname = PyUnicode_AsUTF8(py_hostname);
|
||||
s->lp_ctx = lpcfg_from_py_object(s, py_lp_ctx);
|
||||
return s;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ static PyObject *py_samdb_set_domain_sid(PyLdbObject *self, PyObject *args)
|
||||
|
||||
PyErr_LDB_OR_RAISE(py_ldb, ldb);
|
||||
|
||||
sid = dom_sid_parse_talloc(NULL, PyStr_AsString(py_sid));
|
||||
sid = dom_sid_parse_talloc(NULL, PyUnicode_AsUTF8(py_sid));
|
||||
if (sid == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
@ -782,7 +782,7 @@ static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
|
||||
PyErr_LDB_OR_RAISE(py_ldb, ldb);
|
||||
GUID_from_string(PyStr_AsString(py_guid), &guid);
|
||||
GUID_from_string(PyUnicode_AsUTF8(py_guid), &guid);
|
||||
|
||||
if (GUID_all_zero(&guid)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "set_ntds_invocation_id rejected due to all-zero invocation ID");
|
||||
@ -1282,7 +1282,7 @@ static PyObject *py_dsdb_garbage_collect_tombstones(PyObject *self, PyObject *ar
|
||||
length = PyList_GET_SIZE(py_list_dn);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
const char *part_str = PyStr_AsString(PyList_GetItem(py_list_dn, i));
|
||||
const char *part_str = PyUnicode_AsUTF8(PyList_GetItem(py_list_dn, i));
|
||||
struct ldb_dn *p;
|
||||
struct dsdb_ldb_dn_list_node *node;
|
||||
|
||||
|
@ -121,7 +121,7 @@ static PyObject *py_mount_hive(PyObject *self, PyObject *args)
|
||||
int i;
|
||||
elements = talloc_array(NULL, const char *, PyList_Size(py_elements));
|
||||
for (i = 0; i < PyList_Size(py_elements); i++)
|
||||
elements[i] = PyStr_AsString(PyList_GetItem(py_elements, i));
|
||||
elements[i] = PyUnicode_AsUTF8(PyList_GetItem(py_elements, i));
|
||||
}
|
||||
|
||||
SMB_ASSERT(ctx != NULL);
|
||||
|
@ -41,7 +41,7 @@ static PyTypeObject *ndr_syntax_id_Type;
|
||||
static bool PyString_AsGUID(PyObject *object, struct GUID *uuid)
|
||||
{
|
||||
NTSTATUS status;
|
||||
status = GUID_from_string(PyStr_AsString(object), uuid);
|
||||
status = GUID_from_string(PyUnicode_AsUTF8(object), uuid);
|
||||
if (NT_STATUS_IS_ERR(status)) {
|
||||
PyErr_SetNTSTATUS(status);
|
||||
return false;
|
||||
|
@ -270,7 +270,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
|
||||
}
|
||||
|
||||
py_domaindn = PyObject_GetAttrString(py_result, "domaindn");
|
||||
result->domaindn = talloc_strdup(mem_ctx, PyStr_AsString(py_domaindn));
|
||||
result->domaindn = talloc_strdup(mem_ctx, PyUnicode_AsUTF8(py_domaindn));
|
||||
|
||||
/* FIXME paths */
|
||||
py_lp_ctx = PyObject_GetAttrString(py_result, "lp");
|
||||
|
@ -538,7 +538,7 @@ static PyObject *py_lp_ctx_getitem(PyObject *self, PyObject *name)
|
||||
PyErr_SetString(PyExc_TypeError, "Only string subscripts are supported");
|
||||
return NULL;
|
||||
}
|
||||
service = lpcfg_service(PyLoadparmContext_AsLoadparmContext(self), PyStr_AsString(name));
|
||||
service = lpcfg_service(PyLoadparmContext_AsLoadparmContext(self), PyUnicode_AsUTF8(name));
|
||||
if (service == NULL) {
|
||||
PyErr_SetString(PyExc_KeyError, "No such section");
|
||||
return NULL;
|
||||
|
@ -39,9 +39,9 @@ _PUBLIC_ struct loadparm_context *lpcfg_from_py_object(TALLOC_CTX *mem_ctx, PyOb
|
||||
if (lp_ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (!lpcfg_load(lp_ctx, PyStr_AsString(py_obj))) {
|
||||
if (!lpcfg_load(lp_ctx, PyUnicode_AsUTF8(py_obj))) {
|
||||
PyErr_Format(PyExc_RuntimeError, "Unable to load %s",
|
||||
PyStr_AsString(py_obj));
|
||||
PyUnicode_AsUTF8(py_obj));
|
||||
return NULL;
|
||||
}
|
||||
return lp_ctx;
|
||||
|
Loading…
Reference in New Issue
Block a user