]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python: Align py_ntstatus.c with py_hresult.c
authorVolker Lendecke <vl@samba.org>
Fri, 30 Jan 2026 11:21:45 +0000 (12:21 +0100)
committerAnoop C S <anoopcs@samba.org>
Sun, 15 Feb 2026 10:42:33 +0000 (10:42 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source4/scripting/bin/gen_ntstatus.py

index 4d58731b525543164eff5172af49e37793ce6ec2..7d575d569713c7e32ca9421f71b3eed91fa51e85 100755 (executable)
@@ -78,6 +78,11 @@ def generatePythonFile(out_file, errors):
     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("static void py_addstr(PyObject *m, NTSTATUS status, const char *name)\n");
+    out_file.write("{\n");
+    out_file.write("\tPyObject *num = PyLong_FromUnsignedLongLong(NT_STATUS_V(status));\n");
+    out_file.write("\tPyModule_AddObject(m, name, num);\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")
@@ -85,9 +90,7 @@ def generatePythonFile(out_file, errors):
     out_file.write("\tif (m == NULL)\n")
     out_file.write("\t\treturn NULL;\n\n")
     for err in errors:
-        line = """\tPyModule_AddObject(m, \"%s\",
-                  \t\tPyLong_FromUnsignedLongLong(NT_STATUS_V(%s)));\n""" % (err.err_define, err.err_define)
-        out_file.write(line)
+        out_file.write(f"\tpy_addstr(m, {err.err_define}, \"{err.err_define}\");\n")
     out_file.write("\n")
     out_file.write("\treturn m;\n")
     out_file.write("}\n")