In py2, `open` has no `encoding` arg, python guesses file encoding from
locale. This could be wrong.
Use `io.open` to open a file, so we can specify encoding in both py2 and
py3.
Also, open file with `r` instead of `rb` for py3.
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
"""Source level Python tests."""
+import io
import errno
import os
import re
"""Iterate over the contents of all python files."""
for fname in get_python_source_files():
try:
- f = open(fname, 'rb')
+ f = io.open(fname, mode='r', encoding='utf-8')
except IOError as e:
if e.errno == errno.ENOENT:
warnings.warn("source file %s broken link?" % fname)
with_pam = ("WITH_PAM" in config_hash)
pam_wrapper_so_path=config_hash["LIBPAM_WRAPPER_SO_PATH"]
-planpythontestsuite("none", "samba.tests.source")
+planpythontestsuite("none", "samba.tests.source", py3_compatible=True)
if have_man_pages_support:
planpythontestsuite("none", "samba.tests.docs")