The branch, master has been updated
       via  0ffe030 python: Make generated modules samba.ntstatus and 
samba.werror Python 3 compatible.
       via  051a3ff python: scripting: Port ntstatus and werror generators to 
Python 3 compatible form.
      from  fe9067b s3:printing: Add NULL check for state_path()

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


- Log -----------------------------------------------------------------
commit 0ffe030c0dcd46b51ffb2f11c03d5b48e93d32b9
Author: Lumir Balhar <[email protected]>
Date:   Tue Aug 8 11:50:30 2017 +0200

    python: Make generated modules samba.ntstatus and samba.werror Python 3 
compatible.
    
    Signed-off-by: Lumir Balhar <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    Reviewed-by: Andrew Bartlet <[email protected]>
    
    Autobuild-User(master): Andreas Schneider <[email protected]>
    Autobuild-Date(master): Tue Aug 22 17:38:17 CEST 2017 on sn-devel-144

commit 051a3ff6eb7dad08202b13aadbc6829370cc3f4b
Author: Lumir Balhar <[email protected]>
Date:   Tue Aug 8 10:56:17 2017 +0200

    python: scripting: Port ntstatus and werror generators to Python 3 
compatible form.
    
    Signed-off-by: Lumir Balhar <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    Reviewed-by: Andrew Bartlet <[email protected]>

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

Summary of changes:
 libcli/util/wscript_build                 | 21 +++++++++++----------
 source4/scripting/bin/gen_error_common.py |  2 +-
 source4/scripting/bin/gen_ntstatus.py     | 24 ++++++++++++++++--------
 source4/scripting/bin/gen_werror.py       | 24 ++++++++++++++++--------
 4 files changed, 44 insertions(+), 27 deletions(-)
 mode change 100644 => 100755 source4/scripting/bin/gen_werror.py


Changeset truncated at 500 lines:

diff --git a/libcli/util/wscript_build b/libcli/util/wscript_build
index f27014e..ce91899 100644
--- a/libcli/util/wscript_build
+++ b/libcli/util/wscript_build
@@ -26,14 +26,15 @@ bld.SAMBA_GENERATOR('werror_generated',
                     rule='${PYTHON} ${SRC[0].abspath(env)} 
${SRC[1].abspath(env)} ${TGT[0].abspath(env)} ${TGT[1].abspath(env)} 
${TGT[2].abspath(env)}'
                    )
 
-bld.SAMBA_PYTHON('python_ntstatus',
-       source='py_ntstatus.c',
-       deps='samba-errors',
-       realname='samba/ntstatus.so'
-       )
+for env in bld.gen_python_environments():
+       bld.SAMBA_PYTHON('python_ntstatus',
+               source='py_ntstatus.c',
+               deps='samba-errors',
+               realname='samba/ntstatus.so'
+               )
 
-bld.SAMBA_PYTHON('python_werror',
-       source='py_werror.c',
-       deps='samba-errors',
-       realname='samba/werror.so'
-       )
+       bld.SAMBA_PYTHON('python_werror',
+               source='py_werror.c',
+               deps='samba-errors',
+               realname='samba/werror.so'
+               )
diff --git a/source4/scripting/bin/gen_error_common.py 
b/source4/scripting/bin/gen_error_common.py
index a55baea..ab86c4d 100644
--- a/source4/scripting/bin/gen_error_common.py
+++ b/source4/scripting/bin/gen_error_common.py
@@ -77,6 +77,6 @@ def parseErrorDescriptions( file_contents, isWinError, 
transformErrorFunction ):
                         else:
                             err.err_string = err.err_string + " " + desc
             count = count + 1
-    print "parsed %d lines generated %d error definitions"%(count,len(errors))
+    print("parsed %d lines generated %d error definitions"%(count,len(errors)))
     return errors
 
diff --git a/source4/scripting/bin/gen_ntstatus.py 
b/source4/scripting/bin/gen_ntstatus.py
index 9592ab2..9e92f49 100755
--- a/source4/scripting/bin/gen_ntstatus.py
+++ b/source4/scripting/bin/gen_ntstatus.py
@@ -70,6 +70,7 @@ def generatePythonFile(out_file, errors):
     out_file.write(" * [MS-ERREF] 
http://msdn.microsoft.com/en-us/library/cc704588.aspx\n";)
     out_file.write(" */\n")
     out_file.write("#include <Python.h>\n")
+    out_file.write("#include \"python/py3compat.h\"\n")
     out_file.write("#include \"includes.h\"\n\n")
     out_file.write("static inline PyObject 
*ndr_PyLong_FromUnsignedLongLong(unsigned long long v)\n");
     out_file.write("{\n");
@@ -82,17 +83,24 @@ def generatePythonFile(out_file, errors):
     # This is needed to avoid a missing prototype error from the C
     # compiler. There is never a prototype for this function, it is a
     # module loaded by python with dlopen() and found with dlsym().
-    out_file.write("void initntstatus(void);\n")
-    out_file.write("void initntstatus(void)\n")
+    out_file.write("static struct PyModuleDef moduledef = {\n")
+    out_file.write("\tPyModuleDef_HEAD_INIT,\n")
+    out_file.write("\t.m_name = \"ntstatus\",\n")
+    out_file.write("\t.m_doc = \"NTSTATUS error defines\",\n")
+    out_file.write("\t.m_size = -1,\n")
+    out_file.write("};\n\n")
+    out_file.write("MODULE_INIT_FUNC(ntstatus)\n")
     out_file.write("{\n")
     out_file.write("\tPyObject *m;\n\n")
-    out_file.write("\tm = Py_InitModule3(\"ntstatus\", NULL, \"NTSTATUS error 
defines\");\n");
+    out_file.write("\tm = PyModule_Create(&moduledef);\n");
     out_file.write("\tif (m == NULL)\n");
-    out_file.write("\t\treturn;\n\n");
+    out_file.write("\t\treturn NULL;\n\n");
     for err in errors:
         line = """\tPyModule_AddObject(m, \"%s\", 
                   \t\tndr_PyLong_FromUnsignedLongLong(NT_STATUS_V(%s)));\n""" 
% (err.err_define, err.err_define)
         out_file.write(line)
+    out_file.write("\n");
+    out_file.write("\treturn m;\n");
     out_file.write("}\n");
 
 def transformErrorName( error_name ):
@@ -122,7 +130,7 @@ def main ():
         gen_sourcefile_name = sys.argv[3]
         gen_pythonfile_name = sys.argv[4]
     else:
-        print "usage: %s winerrorfile headerfile sourcefile pythonfile" % 
(sys.argv[0])
+        print("usage: %s winerrorfile headerfile sourcefile pythonfile" % 
(sys.argv[0]))
         sys.exit()
 
     # read in the data
@@ -130,15 +138,15 @@ def main ():
 
     errors = parseErrorDescriptions(file_contents, False, transformErrorName)
 
-    print "writing new header file: %s" % gen_headerfile_name
+    print("writing new header file: %s" % gen_headerfile_name)
     out_file = open(gen_headerfile_name, "w")
     generateHeaderFile(out_file, errors)
     out_file.close()
-    print "writing new source file: %s" % gen_sourcefile_name
+    print("writing new source file: %s" % gen_sourcefile_name)
     out_file = open(gen_sourcefile_name, "w")
     generateSourceFile(out_file, errors)
     out_file.close()
-    print "writing new python file: %s" % gen_pythonfile_name
+    print("writing new python file: %s" % gen_pythonfile_name)
     out_file = open(gen_pythonfile_name, "w")
     generatePythonFile(out_file, errors)
     out_file.close()
diff --git a/source4/scripting/bin/gen_werror.py 
b/source4/scripting/bin/gen_werror.py
old mode 100644
new mode 100755
index 7210d3f..96611ae
--- a/source4/scripting/bin/gen_werror.py
+++ b/source4/scripting/bin/gen_werror.py
@@ -72,6 +72,7 @@ def generatePythonFile(out_file, errors):
     out_file.write(" * [MS-ERREF] 
https://msdn.microsoft.com/en-us/library/cc231199.aspx\n";)
     out_file.write(" */\n")
     out_file.write("#include <Python.h>\n")
+    out_file.write("#include \"python/py3compat.h\"\n")
     out_file.write("#include \"includes.h\"\n\n")
     out_file.write("static inline PyObject 
*ndr_PyLong_FromUnsignedLongLong(unsigned long long v)\n");
     out_file.write("{\n");
@@ -84,17 +85,24 @@ def generatePythonFile(out_file, errors):
     # This is needed to avoid a missing prototype error from the C
     # compiler. There is never a prototype for this function, it is a
     # module loaded by python with dlopen() and found with dlsym().
-    out_file.write("void initwerror(void);\n")
-    out_file.write("void initwerror(void)\n")
+    out_file.write("static struct PyModuleDef moduledef = {\n")
+    out_file.write("\tPyModuleDef_HEAD_INIT,\n")
+    out_file.write("\t.m_name = \"werror\",\n")
+    out_file.write("\t.m_doc = \"WERROR defines\",\n")
+    out_file.write("\t.m_size = -1,\n")
+    out_file.write("};\n\n")
+    out_file.write("MODULE_INIT_FUNC(werror)\n")
     out_file.write("{\n")
     out_file.write("\tPyObject *m;\n\n")
-    out_file.write("\tm = Py_InitModule3(\"werror\", NULL, \"WERROR 
defines\");\n");
+    out_file.write("\tm = PyModule_Create(&moduledef);\n");
     out_file.write("\tif (m == NULL)\n");
-    out_file.write("\t\treturn;\n\n");
+    out_file.write("\t\treturn NULL;\n\n");
     for err in errors:
         line = """\tPyModule_AddObject(m, \"%s\",
                   \t\tndr_PyLong_FromUnsignedLongLong(W_ERROR_V(%s)));\n""" % 
(err.err_define, err.err_define)
         out_file.write(line)
+    out_file.write("\n");
+    out_file.write("\treturn m;\n");
     out_file.write("}\n");
 
 def transformErrorName( error_name ):
@@ -124,22 +132,22 @@ def main():
         gen_sourcefile_name = sys.argv[3]
         gen_pythonfile_name = sys.argv[4]
     else:
-        print "usage: %s winerrorfile headerfile sourcefile pythonfile" % 
sys.argv[0]
+        print("usage: %s winerrorfile headerfile sourcefile pythonfile" % 
sys.argv[0])
         sys.exit()
 
     input_file = open(input_file_name, "r")
     errors = parseErrorDescriptions(input_file, True, transformErrorName)
     input_file.close()
 
-    print "writing new header file: %s" % gen_headerfile_name
+    print("writing new header file: %s" % gen_headerfile_name)
     out_file = open(gen_headerfile_name, "w")
     generateHeaderFile(out_file, errors)
     out_file.close()
-    print "writing new source file: %s" % gen_sourcefile_name
+    print("writing new source file: %s" % gen_sourcefile_name)
     out_file = open(gen_sourcefile_name, "w")
     generateSourceFile(out_file, errors)
     out_file.close()
-    print "writing new python file: %s" % gen_pythonfile_name
+    print("writing new python file: %s" % gen_pythonfile_name)
     out_file = open(gen_pythonfile_name, "w")
     generatePythonFile(out_file, errors)
     out_file.close()


-- 
Samba Shared Repository

Reply via email to