[issue14007] xml.etree.ElementTree - XMLParser and TreeBuilder's doctype() method missing
Martin Panter
report at bugs.python.org
Mon Oct 28 10:18:43 CET 2013
Martin Panter added the comment:
There is an issue in Python 2.7 (and 3.2 if that matters) with the DeprecationWarning for the doctype() method being triggered internally. It is a bit different from this issue but I think a solution has already been committed for 3.3, and the commit message references this issue. Let me know if I should raise a separate report.
The warning is triggered for the Python version of the ElementTree module:
$ python2.7 -Wall
Python 2.7.5 (default, Sep 6 2013, 09:55:21)
[GCC 4.8.1 20130725 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.etree import ElementTree
>>> ElementTree.XML(b'<!DOCTYPE blaua SYSTEM "id"><elem/>')
/usr/lib/python2.7/xml/etree/ElementTree.py:1627: DeprecationWarning: This method of XMLParser is deprecated. Define doctype() method on the TreeBuilder target.
DeprecationWarning,
/usr/lib/python2.7/xml/etree/ElementTree.py:1627: DeprecationWarning: This method of XMLParser is deprecated. Define doctype() method on the TreeBuilder target.
DeprecationWarning,
<Element 'elem' at 0xd47910>
>>>
Possible solution is the patch hunk below, taken from this commit:
http://hg.python.org/cpython/diff/47016103185f/Lib/xml/etree/ElementTree.py#l1.99
@@ -1636,7 +1627,7 @@ class XMLParser:
pubid = pubid[1:-1]
if hasattr(self.target, "doctype"):
self.target.doctype(name, pubid, system[1:-1])
- elif self.doctype is not self._XMLParser__doctype:
+ elif self.doctype != self._XMLParser__doctype:
# warn about deprecated call
self._XMLParser__doctype(name, pubid, system[1:-1])
self.doctype(name, pubid, system[1:-1])
----------
nosy: +vadmium
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14007>
_______________________________________
More information about the Python-bugs-list
mailing list