mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s4/dsdb: python3 api should take 'bytes'
Attributes are properly represented by 'bytes' and *maybe* can be converted into strings (if they are text). py_dsdb_normalise_attributes currently expects strings, this is fine in python2 however in python3 we need to actually pass a 'bytes' class. Signed-off-by: Noel Power <noel.power@suse.com> Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
4c02d5cafe
commit
0d65c1ef65
@ -625,7 +625,6 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
|
||||
TALLOC_CTX *tmp_ctx;
|
||||
WERROR werr;
|
||||
Py_ssize_t i;
|
||||
Py_ssize_t _size;
|
||||
PyTypeObject *py_type = NULL;
|
||||
PyObject *module = NULL;
|
||||
|
||||
@ -688,13 +687,16 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
|
||||
|
||||
for (i = 0; i < el->num_values; i++) {
|
||||
PyObject *item = PyList_GetItem(el_list, i);
|
||||
if (!PyStr_Check(item)) {
|
||||
PyErr_Format(PyExc_TypeError, "ldif_elements should be strings");
|
||||
if (!PyBytes_Check(item)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"ldif_element type should be "
|
||||
PY_DESC_PY3_BYTES
|
||||
);
|
||||
talloc_free(tmp_ctx);
|
||||
return NULL;
|
||||
}
|
||||
el->values[i].data = (uint8_t *)PyStr_AsUTF8AndSize(item, &_size);;
|
||||
el->values[i].length = _size;
|
||||
el->values[i].data = (uint8_t *)PyBytes_AsString(item);
|
||||
el->values[i].length = PyBytes_Size(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user