-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
bpo-29209: Remove old-deprecated features in ElementTree. #6769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
serhiy-storchaka
merged 3 commits into
python:master
from
serhiy-storchaka:etree-remove-deprecated
Jul 24, 2018
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -412,11 +412,10 @@ def iter(self, tag=None): | |
|
|
||
| # compatibility | ||
| def getiterator(self, tag=None): | ||
| # Change for a DeprecationWarning in 1.4 | ||
| warnings.warn( | ||
| "This method will be removed in future versions. " | ||
| "Use 'elem.iter()' or 'list(elem.iter())' instead.", | ||
| PendingDeprecationWarning, stacklevel=2 | ||
| DeprecationWarning, stacklevel=2 | ||
| ) | ||
| return list(self.iter(tag)) | ||
|
|
||
|
|
@@ -622,11 +621,10 @@ def iter(self, tag=None): | |
|
|
||
| # compatibility | ||
| def getiterator(self, tag=None): | ||
| # Change for a DeprecationWarning in 1.4 | ||
| warnings.warn( | ||
| "This method will be removed in future versions. " | ||
| "Use 'tree.iter()' or 'list(tree.iter())' instead.", | ||
| PendingDeprecationWarning, stacklevel=2 | ||
| DeprecationWarning, stacklevel=2 | ||
| ) | ||
| return list(self.iter(tag)) | ||
|
|
||
|
|
@@ -1431,25 +1429,19 @@ def end(self, tag): | |
| self._tail = 1 | ||
| return self._last | ||
|
|
||
| _sentinel = ['sentinel'] | ||
|
|
||
| # also see ElementTree and TreeBuilder | ||
| class XMLParser: | ||
| """Element structure builder for XML source data based on the expat parser. | ||
|
|
||
| *html* are predefined HTML entities (deprecated and not supported), | ||
| *target* is an optional target object which defaults to an instance of the | ||
| standard TreeBuilder class, *encoding* is an optional encoding string | ||
| which if given, overrides the encoding specified in the XML file: | ||
| http://www.iana.org/assignments/character-sets | ||
|
|
||
| """ | ||
|
|
||
| def __init__(self, html=_sentinel, target=None, encoding=None): | ||
| if html is not _sentinel: | ||
| warnings.warn( | ||
| "The html argument of XMLParser() is deprecated", | ||
| DeprecationWarning, stacklevel=2) | ||
| def __init__(self, *, target=None, encoding=None): | ||
| try: | ||
| from xml.parsers import expat | ||
| except ImportError: | ||
|
|
@@ -1602,27 +1594,13 @@ def _default(self, text): | |
| return | ||
| if hasattr(self.target, "doctype"): | ||
| self.target.doctype(name, pubid, system[1:-1]) | ||
| 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]) | ||
| self._doctype = None | ||
|
|
||
| def doctype(self, name, pubid, system): | ||
| """(Deprecated) Handle doctype declaration | ||
|
|
||
| *name* is the Doctype name, *pubid* is the public identifier, | ||
| and *system* is the system identifier. | ||
| elif hasattr(self, "doctype"): | ||
| warnings.warn( | ||
| "The doctype() method of XMLParser is ignored. " | ||
| "Define doctype() method on the TreeBuilder target.", | ||
| RuntimeWarning) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here add versions ? |
||
|
|
||
| """ | ||
| warnings.warn( | ||
| "This method of XMLParser is deprecated. Define doctype() " | ||
| "method on the TreeBuilder target.", | ||
| DeprecationWarning, | ||
| ) | ||
|
|
||
| # sentinel, if doctype is redefined in a subclass | ||
| __doctype = doctype | ||
| self._doctype = None | ||
|
|
||
| def feed(self, data): | ||
| """Feed encoded data to parser.""" | ||
|
|
||
6 changes: 6 additions & 0 deletions
6
Misc/NEWS.d/next/Library/2018-05-12-13-06-41.bpo-29209.h5RxYy.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Removed the ``doctype()`` method and the *html* parameter of the constructor | ||
| of :class:`~xml.etree.ElementTree.XMLParser`. The ``doctype()`` method | ||
| defined in a subclass will no longer be called. Deprecated methods | ||
| ``getchildren()`` and ``getiterator()`` in the :mod:`~xml.etree.ElementTree` | ||
| module emit now a :exc:`DeprecationWarning` instead of | ||
| :exc:`PendingDeprecationWarning`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to update the messages to have the version since the deprecation and the planned removal version here (and on line 418) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in the documentation.