LDB python3 strings
abartlet at samba.org
Wed May 9 08:06:50 UTC 2018
On Wed, 2018-05-09 at 08:20 +0100, Noel Power wrote:
> Unfortunately this doesn't help with the instance where just plain
> res["samAccountName"] is being passed around (which seem to be the
> ones that I have had to change lots of). Perhaps
> str(res["samAccountName"]) is used more than I realise but I just
> haven't experienced that yet (at least in terms of root causes of
> runtime errors when porting tests)
Indeed, and I don't mind .decode('utf8') but the reason I want the
str() thing is a bit more subtle.
It comes back to what Douglas writes above, or more particularly what
happens without an exception if we don't.
x = str(res[samAccountName])
As I understand it, in this case x == "b'abartlet'" in Python3 but
'abartlet' in python2. If it threw an exception we would be fine, but
the silent b'' wrapping will be a nightmare to chase though.
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Catalyst IT http://catalyst.net.nz/services/samba
More information about the samba-technical