1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-02 20:42:30 +03:00

Warn when using deprecated functions from Python bindings

This requires Python code to be run with -Wd.
This commit is contained in:
Nick Wellnhofer
2022-03-01 13:57:16 +01:00
parent b66ce0bba8
commit ebc5009793
3 changed files with 47 additions and 3 deletions

View File

@ -295,8 +295,6 @@ deprecated_funcs = {
}
def skip_function(name):
if name in deprecated_funcs:
return 1
if name[0:12] == "xmlXPathWrap":
return 1
if name == "xmlFreeParserCtxt":
@ -371,6 +369,8 @@ def print_function_wrapper(name, output, export, include):
# Don't delete the function entry in the caller.
return 1
is_deprecated = name in deprecated_funcs
c_call = ""
format=""
format_args=""
@ -484,6 +484,8 @@ def print_function_wrapper(name, output, export, include):
output.write("#endif\n")
return 1
if is_deprecated:
output.write("XML_IGNORE_DEPRECATION_WARNINGS\n")
output.write("PyObject *\n")
output.write("libxml_%s(PyObject *self ATTRIBUTE_UNUSED," % (name))
output.write(" PyObject *args")
@ -496,6 +498,10 @@ def print_function_wrapper(name, output, export, include):
output.write(c_return)
if c_args != "":
output.write(c_args)
if is_deprecated:
output.write("\n if (libxml_deprecationWarning(\"%s\") == -1)\n" %
name)
output.write(" return(NULL);\n")
if format != "":
output.write("\n if (!PyArg_ParseTuple(args, (char *)\"%s\"%s))\n" %
(format, format_args))
@ -507,7 +513,11 @@ def print_function_wrapper(name, output, export, include):
if c_release != "":
output.write(c_release)
output.write(ret_convert)
output.write("}\n\n")
output.write("}\n")
if is_deprecated:
output.write("XML_POP_WARNINGS\n")
output.write("\n")
if cond != None and cond != "":
include.write("#endif /* %s */\n" % cond)
export.write("#endif /* %s */\n" % cond)