The branch, master has been updated
       via  1116ee1 selftest: Actually run python3 tests during the selftest
       via  e99c0e6 python3:tests: Fix Python 3 test issues
       via  40e409b python3: Use "y#" instead of "s#" for binary data in 
PyArg_ParseTuple
      from  b691f6d s3: smbd: Fix open_files.idl to correctly ignore 
share_mode_lease *lease in share_mode_entry.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1116ee1c5c47b405666a0d52f646d05613a803ab
Author: Andrew Bartlett <abart...@samba.org>
Date:   Tue May 2 12:55:45 2017 +0200

    selftest: Actually run python3 tests during the selftest
    
    These previously only ran if the develper was using EXTRA_PYTHON in their
    OS environment
    
    Signed-off-by: Andrew Bartlett <abart...@samba.org>
    Reviewed-by: Andreas Schneider <a...@samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abart...@samba.org>
    Autobuild-Date(master): Sat May 20 02:26:33 CEST 2017 on sn-devel-144

commit e99c0e6503d5cfa048c62b0a6d954d3e7504ff62
Author: Petr Viktorin <pvikt...@redhat.com>
Date:   Wed May 3 19:11:03 2017 +0200

    python3:tests: Fix Python 3 test issues
    
    - Forgotten text strings that should be binary
    - Inverted PY3 condition
    
    Signed-off-by: Petr Viktorin <pvikt...@redhat.com>
    Reviewed-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

commit 40e409bf9e89a163c771b2a58493d2c1b496fae7
Author: Petr Viktorin <pvikt...@redhat.com>
Date:   Wed May 3 16:57:07 2017 +0200

    python3: Use "y#" instead of "s#" for binary data in PyArg_ParseTuple
    
    The "s#" format code for PyArg_ParseTupleAndKeywords and Py_BuildValue
    converts a char* and size to/from Python str (with utf-8 encoding under
    Python 3).
    In some cases, we want bytes (str on Python 2, bytes on 3) instead. The
    code for this is "y#" in Python 3, but that is not available in 2.
    
    Introduce a PYARG_BYTES_LEN macro that expands to "s#" or "y#", and use
    that in:
    - credentials.get_ntlm_response (for input and output)
    - ndr_unpack argument in PIDL generated code
    
    Signed-off-by: Petr Viktorin <pvikt...@redhat.com>
    Reviewed-by: Andreas Schneider <a...@samba.org>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 auth/credentials/pycredentials.c     | 6 ++++--
 pidl/lib/Parse/Pidl/Samba4/Python.pm | 6 +++---
 python/py3compat.h                   | 8 ++++++++
 python/samba/tests/core.py           | 4 ++--
 python/samba/tests/dcerpc/misc.py    | 2 +-
 selftest/selftesthelpers.py          | 2 +-
 selftest/wscript                     | 4 ++++
 7 files changed, 23 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c
index 7f03f1f..283a73f 100644
--- a/auth/credentials/pycredentials.c
+++ b/auth/credentials/pycredentials.c
@@ -96,7 +96,8 @@ static PyObject *py_creds_get_ntlm_response(PyObject *self, 
PyObject *args, PyOb
        tv_now = timeval_current();
        server_timestamp = timeval_to_nttime(&tv_now);
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "is#|s#K",
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                        "i" PYARG_BYTES_LEN "|" 
PYARG_BYTES_LEN "K",
                                         discard_const_p(char *, kwnames),
                                         &flags, &challenge, &target_info.data, 
&target_info.length)) {
                return NULL;
@@ -116,7 +117,8 @@ static PyObject *py_creds_get_ntlm_response(PyObject *self, 
PyObject *args, PyOb
                return NULL;
        }
 
-       ret = Py_BuildValue("{siss#ss#ss#ss#}",
+       ret = Py_BuildValue("{sis" PYARG_BYTES_LEN "s" PYARG_BYTES_LEN
+                                   "s" PYARG_BYTES_LEN "s" PYARG_BYTES_LEN "}",
                            "flags", flags,
                            "lm_reponse",
                            (const char *)lm_response.data, lm_response.length,
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm 
b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index e40f4f1..79beb2e 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -320,7 +320,7 @@ sub PythonStruct($$$$$$)
                $self->pidl("PyObject *allow_remaining_obj = NULL;");
                $self->pidl("bool allow_remaining = false;");
                $self->pidl("");
-               $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
\"s#|O:__ndr_unpack__\",");
+               $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
PYARG_BYTES_LEN \"|O:__ndr_unpack__\",");
                $self->indent;
                $self->pidl("discard_const_p(char *, kwnames),");
                $self->pidl("&blob.data, &blob_length,");
@@ -705,7 +705,7 @@ sub PythonFunctionStruct($$$$)
        $self->pidl("PyObject *allow_remaining_obj = NULL;");
        $self->pidl("bool allow_remaining = false;");
        $self->pidl("");
-       $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
\"s#|OOO:__ndr_unpack_in__\",");
+       $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
PYARG_BYTES_LEN \"|OOO:__ndr_unpack_in__\",");
        $self->indent;
        $self->pidl("discard_const_p(char *, kwnames),");
        $self->pidl("&blob.data, &blob_length,");
@@ -753,7 +753,7 @@ sub PythonFunctionStruct($$$$)
        $self->pidl("PyObject *allow_remaining_obj = NULL;");
        $self->pidl("bool allow_remaining = false;");
        $self->pidl("");
-       $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
\"s#|OOO:__ndr_unpack_out__\",");
+       $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
PYARG_BYTES_LEN \"|OOO:__ndr_unpack_out__\",");
        $self->indent;
        $self->pidl("discard_const_p(char *, kwnames),");
        $self->pidl("&blob.data, &blob_length,");
diff --git a/python/py3compat.h b/python/py3compat.h
index c7724c9..f54b391 100644
--- a/python/py3compat.h
+++ b/python/py3compat.h
@@ -98,6 +98,10 @@
     PyMODINIT_FUNC PyInit_ ## name(void); \
     PyMODINIT_FUNC PyInit_ ## name(void)
 
+/* PyArg_ParseTuple/Py_BuildValue argument */
+
+#define PYARG_BYTES_LEN "y#"
+
 #else
 
 /***** Python 2 *****/
@@ -140,6 +144,10 @@
 #define PyBytes_ConcatAndDel PyString_ConcatAndDel
 #define _PyBytes_Resize _PyString_Resize
 
+/* PyArg_ParseTuple/Py_BuildValue argument */
+
+#define PYARG_BYTES_LEN "s#"
+
 /* Module init */
 
 #define PyModuleDef_HEAD_INIT 0
diff --git a/python/samba/tests/core.py b/python/samba/tests/core.py
index 7fb3698..504d458 100644
--- a/python/samba/tests/core.py
+++ b/python/samba/tests/core.py
@@ -52,8 +52,8 @@ class SubstituteVarTestCase(TestCase):
 class ArcfourTestCase(TestCase):
 
     def test_arcfour_direct(self):
-        key = '12345678'
-        plain = 'abcdefghi'
+        key = b'12345678'
+        plain = b'abcdefghi'
         crypt_expected = b'\xda\x91Z\xb0l\xd7\xb9\xcf\x99'
         crypt_calculated = arcfour_encrypt(key, plain)
         self.assertEquals(crypt_expected, crypt_calculated)
diff --git a/python/samba/tests/dcerpc/misc.py 
b/python/samba/tests/dcerpc/misc.py
index 68654a7..2ec0950 100644
--- a/python/samba/tests/dcerpc/misc.py
+++ b/python/samba/tests/dcerpc/misc.py
@@ -25,7 +25,7 @@ text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
 text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
 
 
-if not PY3:
+if PY3:
     # cmp() exists only in Python 2
     def cmp(a, b):
         return (a > b) - (a < b)
diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py
index 6b22a16..8b885b5 100644
--- a/selftest/selftesthelpers.py
+++ b/selftest/selftesthelpers.py
@@ -140,7 +140,7 @@ def planpythontestsuite(env, module, name=None, 
extra_path=[], py3_compatible=Fa
     if py3_compatible and extra_python is not None:
         # Plan one more test for Python 3 compatible module
         args[0] = extra_python
-        plantestsuite_loadlist(name, env, args)
+        plantestsuite_loadlist(name + ".python3", env, args)
 
 
 def get_env_torture_options():
diff --git a/selftest/wscript b/selftest/wscript
index 2299195..d8094af 100644
--- a/selftest/wscript
+++ b/selftest/wscript
@@ -209,6 +209,10 @@ def cmd_testonly(opt):
         env.TESTLISTS = '--testlist=%r' % Options.options.TEST_LIST
     elif Options.options.PERF_TEST:
         env.TESTLISTS = '--testlist="${PYTHON} 
${srcdir}/selftest/perf_tests.py|" '
+    elif CONFIG_SET(opt, 'EXTRA_PYTHON'):
+        env.TESTLISTS = ('--testlist="EXTRA_PYTHON=${EXTRA_PYTHON} ${PYTHON} 
${srcdir}/selftest/tests.py|" ' +
+                         '--testlist="EXTRA_PYTHON=${EXTRA_PYTHON} ${PYTHON} 
${srcdir}/source3/selftest/tests.py|" ' +
+                         '--testlist="EXTRA_PYTHON=${EXTRA_PYTHON} ${PYTHON} 
${srcdir}/source4/selftest/tests.py|"')
     else:
         env.TESTLISTS = ('--testlist="${PYTHON} ${srcdir}/selftest/tests.py|" 
' +
                          '--testlist="${PYTHON} 
${srcdir}/source3/selftest/tests.py|" ' +


-- 
Samba Shared Repository

Reply via email to