s4/dsdb/tests/python: PY3 allow test samba4.ldap.sort pass
authorNoel Power <noel.power@suse.com>
Wed, 21 Nov 2018 12:39:56 +0000 (12:39 +0000)
committerNoel Power <npower@samba.org>
Mon, 10 Dec 2018 09:38:24 +0000 (10:38 +0100)
commit34ca15fb042e42773854c093ad9f1e67696c90ac
treeb42614df25231b17eb9dc38ae6ee7659d5b83375
parentc319684d5166db944b5b9e88a876d22f4f856993
s4/dsdb/tests/python: PY3 allow test samba4.ldap.sort pass

Adjust test data to remove use of embedded NULLs.

We are getting the following exception when running the test
under python3

Exception: Exception: Traceback (most recent call last):
  File "source4/dsdb/tests/python/sort.py", line 181, in setUp
    key=cmp_to_key_fn(locale.strcoll))
ValueError: embedded null character

Looking at the source code for locale.strcoll the lhs & rhs
params are processed using 'PyUnicode_AsWideCharString(s, NULL)'

Documentation for PyUnicode_AsWideCharString states:

"Convert the Unicode object to a wide character string.
 The output string always ends with a null character. If size is
 not NULL, write the number of wide characters (excluding the
 trailing null termination character) into *size. Note that the
 resulting wchar_t string might contain null characters, which
 would cause the string to be truncated when used with most C
 functions. If size is NULL and the wchar_t* string contains null
 characters a ValueError is raised."

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