1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Mon, 29 Aug 2022 17:21:19 +0200
Subject: Migrate from PyEval_ to PyObject_
PyEval_ functions are deprecated.
Fixes #208.
Bug-Upstream: https://gitlab.gnome.org/GNOME/libxml2/-/issues/208
Bug-Debian: https://bugs.debian.org/1084096
---
python/libxml.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/python/libxml.c b/python/libxml.c
index 65a51af..3788977 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -257,7 +257,7 @@ xmlPythonFileCloseRaw (void * context) {
#endif
file = (PyObject *) context;
if (file == NULL) return(-1);
- ret = PyEval_CallMethod(file, (char *) "close", (char *) "()");
+ ret = PyObject_CallMethod(file, (char *) "close", (char *) "()");
if (ret != NULL) {
Py_DECREF(ret);
}
@@ -287,7 +287,7 @@ xmlPythonFileReadRaw (void * context, char * buffer, int len) {
#endif
file = (PyObject *) context;
if (file == NULL) return(-1);
- ret = PyEval_CallMethod(file, (char *) "read", (char *) "(i)", len);
+ ret = PyObject_CallMethod(file, (char *) "read", (char *) "(i)", len);
if (ret == NULL) {
printf("xmlPythonFileReadRaw: result is NULL\n");
return(-1);
@@ -352,7 +352,7 @@ xmlPythonFileRead (void * context, char * buffer, int len) {
#endif
file = (PyObject *) context;
if (file == NULL) return(-1);
- ret = PyEval_CallMethod(file, (char *) "io_read", (char *) "(i)", len);
+ ret = PyObject_CallMethod(file, (char *) "io_read", (char *) "(i)", len);
if (ret == NULL) {
printf("xmlPythonFileRead: result is NULL\n");
return(-1);
@@ -420,10 +420,10 @@ xmlPythonFileWrite (void * context, const char * buffer, int len) {
string = PY_IMPORT_STRING_SIZE(buffer, len);
if (string == NULL) return(-1);
if (PyObject_HasAttrString(file, (char *) "io_write")) {
- ret = PyEval_CallMethod(file, (char *) "io_write", (char *) "(O)",
+ ret = PyObject_CallMethod(file, (char *) "io_write", (char *) "(O)",
string);
} else if (PyObject_HasAttrString(file, (char *) "write")) {
- ret = PyEval_CallMethod(file, (char *) "write", (char *) "(O)",
+ ret = PyObject_CallMethod(file, (char *) "write", (char *) "(O)",
string);
}
Py_DECREF(string);
@@ -459,9 +459,9 @@ xmlPythonFileClose (void * context) {
file = (PyObject *) context;
if (file == NULL) return(-1);
if (PyObject_HasAttrString(file, (char *) "io_close")) {
- ret = PyEval_CallMethod(file, (char *) "io_close", (char *) "()");
+ ret = PyObject_CallMethod(file, (char *) "io_close", (char *) "()");
} else if (PyObject_HasAttrString(file, (char *) "flush")) {
- ret = PyEval_CallMethod(file, (char *) "flush", (char *) "()");
+ ret = PyObject_CallMethod(file, (char *) "flush", (char *) "()");
}
if (ret != NULL) {
Py_DECREF(ret);
@@ -1649,7 +1649,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg,
Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
message = libxml_charPtrConstWrap(ptr);
PyTuple_SetItem(list, 1, message);
- result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
+ result = PyObject_CallObject(libxml_xmlPythonErrorFuncHandler, list);
/* Forget any errors caused in the error handler. */
PyErr_Clear();
Py_XDECREF(list);
@@ -1739,7 +1739,7 @@ libxml_xmlParserCtxtGenericErrorFuncHandler(void *ctx, int severity, char *str)
PyTuple_SetItem(list, 2, libxml_intWrap(severity));
PyTuple_SetItem(list, 3, Py_None);
Py_INCREF(Py_None);
- result = PyEval_CallObject(pyCtxt->f, list);
+ result = PyObject_CallObject(pyCtxt->f, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
@@ -1925,7 +1925,7 @@ libxml_xmlValidCtxtGenericErrorFuncHandler(void *ctx, ATTRIBUTE_UNUSED int sever
PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
PyTuple_SetItem(list, 1, pyCtxt->arg);
Py_XINCREF(pyCtxt->arg);
- result = PyEval_CallObject(pyCtxt->error, list);
+ result = PyObject_CallObject(pyCtxt->error, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
@@ -1952,7 +1952,7 @@ libxml_xmlValidCtxtGenericWarningFuncHandler(void *ctx, ATTRIBUTE_UNUSED int sev
PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
PyTuple_SetItem(list, 1, pyCtxt->arg);
Py_XINCREF(pyCtxt->arg);
- result = PyEval_CallObject(pyCtxt->warn, list);
+ result = PyObject_CallObject(pyCtxt->warn, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
@@ -2087,7 +2087,7 @@ libxml_xmlTextReaderErrorCallback(void *arg,
PyTuple_SetItem(list, 1, libxml_charPtrConstWrap(msg));
PyTuple_SetItem(list, 2, libxml_intWrap(severity));
PyTuple_SetItem(list, 3, libxml_xmlTextReaderLocatorPtrWrap(locator));
- result = PyEval_CallObject(pyCtxt->f, list);
+ result = PyObject_CallObject(pyCtxt->f, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
@@ -2282,7 +2282,7 @@ libxml_xmlXPathFuncCallback(xmlXPathParserContextPtr ctxt, int nargs)
cur = libxml_xmlXPathObjectPtrWrap(obj);
PyTuple_SetItem(list, i + 1, cur);
}
- result = PyEval_CallObject(current_function, list);
+ result = PyObject_CallObject(current_function, list);
Py_DECREF(list);
obj = libxml_xmlXPathObjectPtrConvert(result);
@@ -3185,7 +3185,7 @@ libxml_xmlRelaxNGValidityGenericErrorFuncHandler(void *ctx, char *str)
PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
PyTuple_SetItem(list, 1, pyCtxt->arg);
Py_XINCREF(pyCtxt->arg);
- result = PyEval_CallObject(pyCtxt->error, list);
+ result = PyObject_CallObject(pyCtxt->error, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
@@ -3212,7 +3212,7 @@ libxml_xmlRelaxNGValidityGenericWarningFuncHandler(void *ctx, char *str)
PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
PyTuple_SetItem(list, 1, pyCtxt->arg);
Py_XINCREF(pyCtxt->arg);
- result = PyEval_CallObject(pyCtxt->warn, list);
+ result = PyObject_CallObject(pyCtxt->warn, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
@@ -3349,7 +3349,7 @@ libxml_xmlSchemaValidityGenericErrorFuncHandler(void *ctx, char *str)
PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
PyTuple_SetItem(list, 1, pyCtxt->arg);
Py_XINCREF(pyCtxt->arg);
- result = PyEval_CallObject(pyCtxt->error, list);
+ result = PyObject_CallObject(pyCtxt->error, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
@@ -3376,7 +3376,7 @@ libxml_xmlSchemaValidityGenericWarningFuncHandler(void *ctx, char *str)
PyTuple_SetItem(list, 0, libxml_charPtrWrap(str));
PyTuple_SetItem(list, 1, pyCtxt->arg);
Py_XINCREF(pyCtxt->arg);
- result = PyEval_CallObject(pyCtxt->warn, list);
+ result = PyObject_CallObject(pyCtxt->warn, list);
if (result == NULL)
{
/* TODO: manage for the exception to be propagated... */
|