Skip to content
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

Add code deprecations in ElementTree #73390

Closed
serhiy-storchaka opened this issue Jan 8, 2017 · 6 comments
Closed

Add code deprecations in ElementTree #73390

serhiy-storchaka opened this issue Jan 8, 2017 · 6 comments
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 29204
Nosy @scoder, @ned-deily, @vadmium, @serhiy-storchaka
PRs
  • bpo-29204: Emit warnings for already deprecated ElementTree features. #773
  • bpo-29204: Add version since deprecation in XMLParser warnings #6763
  • Files
  • etree_deprecations.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-03-30.15:27:42.080>
    created_at = <Date 2017-01-08.11:13:23.415>
    labels = ['extension-modules', 'type-feature', 'library', '3.7']
    title = 'Add code deprecations in ElementTree'
    updated_at = <Date 2018-05-11.03:02:18.130>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-05-11.03:02:18.130>
    actor = 'mbussonn'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-03-30.15:27:42.080>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules', 'Library (Lib)']
    creation = <Date 2017-01-08.11:13:23.415>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['46211']
    hgrepos = []
    issue_num = 29204
    keywords = ['patch']
    message_count = 6.0
    messages = ['284975', '284980', '284985', '284987', '290850', '290852']
    nosy_count = 5.0
    nosy_names = ['scoder', 'ned.deily', 'eli.bendersky', 'martin.panter', 'serhiy.storchaka']
    pr_nums = ['773', '6763']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue29204'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    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?

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jan 8, 2017
    @vadmium
    Copy link
    Member

    vadmium commented Jan 8, 2017

    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.

    @serhiy-storchaka
    Copy link
    Member Author

    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

    @scoder
    Copy link
    Contributor

    scoder commented Jan 8, 2017

    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.

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 762ec97 by Serhiy Storchaka in branch 'master':
    bpo-29204: Emit warnings for already deprecated ElementTree features. (#773)
    762ec97

    @serhiy-storchaka
    Copy link
    Member Author

    The deprecation of the cElementTree module was excluded.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants