New submission from Martin Panter:

I am using the C version of Element Tree via the main ElementTree module. I 
have subclassed XMLParser, and created my own target object. I am not that 
interested in XML doctypes, but the following simplified code raises a 
DeprecationWarning:

$ python3.3 -Wall
Python 3.3.2 (default, May 16 2013, 23:40:52) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.etree.ElementTree import XMLParser
>>> class CustomParser(XMLParser): pass
... 
>>> CustomParser().feed("<!DOCTYPE blaua>")
__main__:1: DeprecationWarning: This method of XMLParser is deprecated.  Define 
doctype() method on the TreeBuilder target.

Looking at the C code, the logic is wrong. Subclasses of XMLParser will 
normally always have a doctype() method, at least by inheritance. So the code 
should compare the method with the XMLParser.doctype() base method rather than 
just checking that it exists. The native Python version seems to get it right.

http://hg.python.org/cpython/file/50ea4dccb03e/Modules/_elementtree.c#l3091

It looks like this may not be an issue for Python 3.4 because according to 
Issue 13248 the deprecated doctype() method is due to be removed.

----------
components: Extension Modules
messages: 199031
nosy: vadmium
priority: normal
severity: normal
status: open
title: DeprecationWarning for doctype() method when subclassing 
_elementtree.XMLParser
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19176>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to