This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add code deprecations in ElementTree
Type: enhancement Stage: resolved
Components: Extension Modules, Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eli.bendersky, martin.panter, ned.deily, scoder, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-01-08 11:13 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
etree_deprecations.patch serhiy.storchaka, 2017-01-08 11:13 review
Pull Requests
URL Status Linked Edit
PR 773 merged serhiy.storchaka, 2017-03-22 21:30
PR 6763 closed mbussonn, 2018-05-11 03:02
Messages (6)
msg284975 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-08 11:13
Some deprecated ElementTree features are deprecated only in the documentation or in Python implementation (that is virtually the same since C implementation is default). Proposed patch adds missed deprecations is code. It also makes warnings be ignored only in tests where they are expected. This is possible since converting doctests to unittests some time ago.

Added deprecations:

* Element.getchildren() and Element.getiterator() methods. They were deprecated in the documentation and in Python implementation in 2.7 and 3.2.

* The xml.etree.cElementTree module. Deprecated in the documentation in 3.3.

* The html argument of XMLParser. Deprecated in the documentation in 3.4.

Ned, is it appropriate to commit the patch (or its part) in 3.6? The discrepancy between Python and C implementation can be considered as a bug. What are your thoughts?
msg284980 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-01-08 11:31
Isn’t cElementTree useful and recommended in 2.7? It would be awkward to deprecate it in Python 3. But I guess the other cases should be okay to deprecate in 3.7.
msg284985 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-08 11:56
Yes, I have a doubt about this too.

Perhaps it can be just removed. The idiomatic code in Python 2 is:

try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
msg284987 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2017-01-08 12:22
I'm ok with the deprecations.

Regarding the cElementTree module, this is a bit problematic. The idiomatic import has lost its use in Py2.5 when ET and cET were added to the stdlib, so code that was written for Py2.5 or later (e.g. because it uses generators) might no longer have that cascade. On the other hand, issuing a warning for the module would also hit this import cascade, even though the code would work just fine without cElementTree. One argument speaks for deprecation, the other for removal.

However, cElementTree is redundant now, so it should be removed eventually. And since that removal would break some code anyway, I'd be ok with just removing it without prior import warnings. People can then decide whether they want to fix their code by adding the well-known import cascade (and not get annoying warnings for it) or by switching entirely to plain ET and not looking back.
msg290850 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-30 15:12
New changeset 762ec97ea68a1126b8855996c61fa8239dc9fff7 by Serhiy Storchaka in branch 'master':
bpo-29204: Emit warnings for already deprecated ElementTree features. (#773)
https://github.com/python/cpython/commit/762ec97ea68a1126b8855996c61fa8239dc9fff7
msg290852 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-30 15:27
The deprecation of the cElementTree module was excluded.
History
Date User Action Args
2022-04-11 14:58:41adminsetgithub: 73390
2018-05-11 03:02:18mbussonnsetpull_requests: + pull_request6450
2017-03-30 15:27:42serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg290852

stage: patch review -> resolved
2017-03-30 15:12:10serhiy.storchakasetmessages: + msg290850
2017-03-22 21:30:07serhiy.storchakasetpull_requests: + pull_request679
2017-01-08 17:56:53serhiy.storchakalinkissue29209 dependencies
2017-01-08 12:22:25scodersetmessages: + msg284987
2017-01-08 11:56:39serhiy.storchakasetmessages: + msg284985
2017-01-08 11:31:04martin.pantersetnosy: + martin.panter
messages: + msg284980
2017-01-08 11:13:41serhiy.storchakasetnosy: + scoder, eli.bendersky
2017-01-08 11:13:23serhiy.storchakacreate