Issue description:
I discovered which seems to be a bug in the add_s-function of python-ldap.
The following examples are reduced to contain only the relevant data, these aren't complete datasets.
When I do the following:
con.add_s(dn, [("objectClass", "person")])
I get the following exception:
TypeError: ('Tuple_to_LDAPMod(): expected a byte string in the list', 'p')
It only works, when I do the following:
con.add_s(dn, [("objectClass", b"person")])
However, the documentation under https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#ldap.LDAPObject.add_s clearly states:
The modlist is similar the one passed to modify(), except that the operation integer is omitted from the tuples in modlist.
In the respective section it states:
Each element in the list modlist should be a tuple of the form (mod_op,mod_type,mod_vals), where mod_op indicates the operation (one of ldap.MOD_ADD, ldap.MOD_DELETE, or ldap.MOD_REPLACE), mod_type is a string indicating the attribute type name, and mod_vals is either a string value or a list of string values to add, delete or replace respectively.
So even though the documentation states, that the modlist can contain a string, the function only accepts a byte-sequence.
This is either a bug in the documentation, or in the implementation.
If I assume, that it's the documentation, that's not up-to-date, the situation even gets worse:
>>> x ={"objectClass": "person"}
>>> ldap.modlist.addModlist(x)
[('objectClass', 'person')]
As you can see, the ldap.modlist library also creates the exact same modlist, I used before.
I expect the library tools to either return a perfectly valid modlist, or nothing at all. So the function should either do the string-to-byte conversion or throw a type error. It definately shouldn't return something which isn't a valid input for the ldap-functions.
Operating system: Linux
Python version: 3.6.9
python-ldap version: 3.3.1
Issue description:
I discovered which seems to be a bug in the add_s-function of python-ldap.
The following examples are reduced to contain only the relevant data, these aren't complete datasets.
When I do the following:
con.add_s(dn, [("objectClass", "person")])I get the following exception:
TypeError: ('Tuple_to_LDAPMod(): expected a byte string in the list', 'p')It only works, when I do the following:
con.add_s(dn, [("objectClass", b"person")])However, the documentation under https://www.python-ldap.org/en/python-ldap-3.3.0/reference/ldap.html#ldap.LDAPObject.add_s clearly states:
In the respective section it states:
So even though the documentation states, that the modlist can contain a string, the function only accepts a byte-sequence.
This is either a bug in the documentation, or in the implementation.
If I assume, that it's the documentation, that's not up-to-date, the situation even gets worse:
>>> x ={"objectClass": "person"}>>> ldap.modlist.addModlist(x)[('objectClass', 'person')]As you can see, the ldap.modlist library also creates the exact same modlist, I used before.
I expect the library tools to either return a perfectly valid modlist, or nothing at all. So the function should either do the string-to-byte conversion or throw a type error. It definately shouldn't return something which isn't a valid input for the ldap-functions.
Operating system: Linux
Python version: 3.6.9
python-ldap version: 3.3.1