You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write binary data (python type bytes) to a jpegPhoto attribute and get errors:
class User(UserMixin, ldap.Entry):
...
jpegPhoto = ldap.Attribute('jpegPhoto')
jpeg = ... # binary data, bytes type
user.jpegPhoto = jpeg
user.save()
This results in "AttributeError: 'int' object has no attribute 'encode'" in Attribute.get_changes_tuple() because it thinks it's a multi-valued attribute of integers.
A slight improvement, now the data is at least accepted as a single value, error is "AttributeError: 'bytes' object has no attribute 'encode'".
class BytesLDAPHackAdapter(bytes):
def encode(self, enc):
return self
jpeg = ... # binary data, bytes type
user.jpegPhoto = [BytesLDAPHackAdapter(jpeg)]
This work-around does the trick by providing a no-op encode member function. But it would be much better if LDAPConn would deal properly with bytes typed data. The problem is that bytes is iterable and not str as far as I can see.
Thank you for a nice library otherwise :-)
The text was updated successfully, but these errors were encountered:
I'm trying to write binary data (python type bytes) to a jpegPhoto attribute and get errors:
This results in "AttributeError: 'int' object has no attribute 'encode'" in Attribute.get_changes_tuple() because it thinks it's a multi-valued attribute of integers.
A slight improvement, now the data is at least accepted as a single value, error is "AttributeError: 'bytes' object has no attribute 'encode'".
This work-around does the trick by providing a no-op encode member function. But it would be much better if LDAPConn would deal properly with bytes typed data. The problem is that bytes is iterable and not str as far as I can see.
Thank you for a nice library otherwise :-)
The text was updated successfully, but these errors were encountered: