python/samba: PY3 don't call str for bytes (or str)
authorNoel Power <noel.power@suse.com>
Tue, 6 Nov 2018 19:58:48 +0000 (19:58 +0000)
committerNoel Power <npower@samba.org>
Mon, 10 Dec 2018 09:38:22 +0000 (10:38 +0100)
commit744acb276c7cfc2e8f859ea960282c6395362602
treefe45bf945ff820f3056e16b0c6133c14a50526f6
parentc99450db4eed3abc3a69833a82b1c906e066e27a
python/samba: PY3 don't call str for bytes (or str)

Note: Fix needed also for gpo.apply

minPwdAge, maxPwdAge, minPwdLength & set_pwdProperties all
have a line like

value = str(value).encode('utf8')

this is a generic type statement I guess to convert int, float etc
to utf8 encoded bytes representing the string value for those.

This worked fine in PY2 but in py3 some routine already are passing
bytes into these methods, in these cases e.g. b'200' will get converted
to "b'200'", this change only performs the conversion above for non
bytes (or str) types by replacing the above with

        if not isinstance(value, binary_type):
            value = str(value).encode('utf8')

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/samdb.py