1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-18 16:08:59 +03:00

python: Switch to *CreateIO functions

Avoid using deprecated struct members.
This commit is contained in:
Nick Wellnhofer
2025-07-31 14:35:11 +02:00
parent d1c3391eaf
commit 7deae0f80f

View File

@@ -462,13 +462,8 @@ xmlOutputBufferCreatePythonFile(PyObject *file,
if (file == NULL) return(NULL);
ret = xmlAllocOutputBuffer(encoder);
if (ret != NULL) {
ret->context = file;
/* Py_INCREF(file); */
ret->writecallback = xmlPythonFileWrite;
ret->closecallback = xmlPythonFileClose;
}
ret = xmlOutputBufferCreateIO(xmlPythonFileWrite, xmlPythonFileClose,
file, encoder);
return(ret);
}
@@ -639,13 +634,8 @@ xmlParserInputBufferCreatePythonFile(PyObject *file,
if (file == NULL) return(NULL);
ret = xmlAllocParserInputBuffer(encoding);
if (ret != NULL) {
ret->context = file;
/* Py_INCREF(file); */
ret->readcallback = xmlPythonFileRead;
ret->closecallback = xmlPythonFileClose;
}
ret = xmlParserInputBufferCreateIO(xmlPythonFileRead, xmlPythonFileClose,
file, encoding);
return(ret);
}
@@ -699,11 +689,10 @@ pythonExternalEntityLoader(const char *URL, const char *ID,
if (PyObject_HasAttrString(ret, "read")) {
xmlParserInputBufferPtr buf;
buf = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
buf = xmlParserInputBufferCreateIO(xmlPythonFileReadRaw,
xmlPythonFileCloseRaw,
ret, XML_CHAR_ENCODING_NONE);
if (buf != NULL) {
buf->context = ret;
buf->readcallback = xmlPythonFileReadRaw;
buf->closecallback = xmlPythonFileCloseRaw;
result = xmlNewIOInputStream(ctxt, buf,
XML_CHAR_ENCODING_NONE);
}