Skip to content

Commit

Permalink
Generate deprecation warnings for old SAX API
Browse files Browse the repository at this point in the history
  • Loading branch information
nwellnhof committed Aug 25, 2022
1 parent 7f7961d commit 51035c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/libxml/SAX2.h
Expand Up @@ -146,6 +146,7 @@ XMLPUBFUN void XMLCALL
int len);

#ifdef LIBXML_SAX1_ENABLED
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlSAXDefaultVersion (int version);
#endif /* LIBXML_SAX1_ENABLED */
Expand Down
15 changes: 15 additions & 0 deletions include/libxml/parser.h
Expand Up @@ -861,11 +861,14 @@ XMLPUBFUN int XMLCALL
/*
* Recovery mode
*/
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlRecoverDoc (const xmlChar *cur);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlRecoverMemory (const char *buffer,
int size);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlRecoverFile (const char *filename);
#endif /* LIBXML_SAX1_ENABLED */
Expand All @@ -878,47 +881,57 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
#ifdef LIBXML_SAX1_ENABLED
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
void *user_data,
const char *filename);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
void *user_data,
const char *buffer,
int size);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseDoc (xmlSAXHandlerPtr sax,
const xmlChar *cur,
int recovery);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseMemory (xmlSAXHandlerPtr sax,
const char *buffer,
int size,
int recovery);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
const char *buffer,
int size,
int recovery,
void *data);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseFile (xmlSAXHandlerPtr sax,
const char *filename,
int recovery);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
const char *filename,
int recovery,
void *data);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseEntity (xmlSAXHandlerPtr sax,
const char *filename);
XML_DEPRECATED
XMLPUBFUN xmlDocPtr XMLCALL
xmlParseEntity (const char *filename);
#endif /* LIBXML_SAX1_ENABLED */

#ifdef LIBXML_VALID_ENABLED
XML_DEPRECATED
XMLPUBFUN xmlDtdPtr XMLCALL
xmlSAXParseDTD (xmlSAXHandlerPtr sax,
const xmlChar *ExternalID,
Expand Down Expand Up @@ -955,6 +968,7 @@ XMLPUBFUN int XMLCALL
const xmlChar *string,
xmlNodePtr *lst,
int recover);
XML_DEPRECATED
XMLPUBFUN int XMLCALL
xmlParseExternalEntity (xmlDocPtr doc,
xmlSAXHandlerPtr sax,
Expand Down Expand Up @@ -984,6 +998,7 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN void XMLCALL
xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
#ifdef LIBXML_SAX1_ENABLED
XML_DEPRECATED
XMLPUBFUN void XMLCALL
xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
const xmlChar* buffer,
Expand Down
6 changes: 6 additions & 0 deletions python/generator.py
Expand Up @@ -310,15 +310,21 @@ def enum(type, name, value):
'xmlNanoFTPProxy': True,
'xmlNanoFTPScanProxy': True,
'xmlNewGlobalNs': True,
'xmlParseEntity': True,
'xmlParseNamespace': True,
'xmlParseQuotedString': True,
'xmlParserHandleReference': True,
'xmlRecoverDoc': True,
'xmlRecoverFile': True,
'xmlRecoverMemory': True,
'xmlRelaxNGCleanupTypes': True,
'xmlRelaxNGInitTypes': True,
'xmlRemoveRef': True,
'xmlSAXDefaultVersion': True,
'xmlScanName': True,
'xmlSchemaCleanupTypes': True,
'xmlSchemaInitTypes': True,
'xmlSetupParserForBuffer': True,
'xmlThrDefDefaultBufferSize': True,
'xmlThrDefLineNumbersDefaultValue': True,
'xmlThrDefPedanticParserDefaultValue': True,
Expand Down
5 changes: 4 additions & 1 deletion python/libxml.c
Expand Up @@ -1524,6 +1524,7 @@ libxml_xmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
const char *URI;
PyObject *pyobj_SAX = NULL;
xmlSAXHandlerPtr SAX = NULL;
xmlParserCtxtPtr ctxt;

if (!PyArg_ParseTuple(args, (char *) "Osi:xmlSAXParseFile", &pyobj_SAX,
&URI, &recover))
Expand All @@ -1540,7 +1541,9 @@ libxml_xmlSAXParseFile(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
SAX = &pythonSaxHandler;
Py_INCREF(pyobj_SAX);
/* The reference is released in pythonEndDocument() */
xmlSAXUserParseFile(SAX, pyobj_SAX, URI);
ctxt = xmlNewSAXParserCtxt(SAX, pyobj_SAX);
xmlCtxtReadFile(ctxt, URI, NULL, 0);
xmlFreeParserCtxt(ctxt);
#endif /* LIBXML_SAX1_ENABLED */
Py_INCREF(Py_None);
return (Py_None);
Expand Down

0 comments on commit 51035c5

Please sign in to comment.