GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — xml.etree.ElementTree.SubElement definition is incorrect / inconsistent with C · Issue #144270 · python/cpython

xml.etree.ElementTree.SubElement definition is incorrect / inconsistent with C #144270

New issue
Copy link
New issue
Copy link
Closed
Closed
xml.etree.ElementTree.SubElement definition is incorrect / inconsistent with C#144270
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@Timmmm
Timmmm
opened on Jan 27, 2026
Issue body actions

Bug report

Bug description:

This code runs fine on Python 3.13.7:

import xml.etree.ElementTree as ET
x = ET.Element("x")
ET.SubElement(x, 0, parent="0")

However, Pyright correctly detects a type error in the SubElement call. SubElement has this Python signature:

def SubElement(parent, tag, attrib={}, **extra):

The parent parameter has already been assigned, so this should fail. I believe the fact that it doesn't is because it's actually using a C implementation, and the C implementation has this type signature:

def SubElement(parent, tag, /, attrib={}, **extra):

Which does allow specifying parent="0".

So I think the solution is just to add that / into the Python code.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

  • gh-144270: Fix xml.etree.ElementTree.SubElement signature inconsistency #144313
  • gh-144270: make SubElement parent and tag positional-only #144845

Activity

  1. Timmmm
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jan 27, 2026
  2. aisk
    added
    topic-XML
    on Jan 27, 2026
  3. python
    deleted a comment from abdulaziz4alanazi4-spec on Jan 27, 2026
  4. StanFromIreland
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Jan 27, 2026
  5. serhiy-storchaka commented on Feb 4, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Feb 4, 2026
    Member
    More actions

    @Timmmm, your idea looks good to me. Are you interesting in creating a PR?

    Reacted by Tim Hutt
  6. NekoAsakura
    added 3 commits that reference this issue on Feb 15, 2026

    pythongh-144270: make SubElement parent and tag positional-only

    d956c30

    pythongh-144270: make SubElement parent and tag positional-only

    1551ff7

    pythongh-144270: make Element and SubElement parameters positional-only

    38af9cf
  7. NekoAsakura
    added a commit that references this issue on Mar 30, 2026

    Merge remote-tracking branch 'upstream/main' into pythongh-144270-sub…

    6f43dc8
  8. serhiy-storchaka
    added a commit that references this issue on Mar 30, 2026

    gh-144270: Make SubElement parent and tag positional-only (GH-144845)

    afd8113
  9. serhiy-storchaka
    closed this as completedon Mar 30, 2026
  10. maurycy
    added a commit that references this issue on Mar 30, 2026

    Merge remote-tracking branch 'upstream/main' into tachyon-ndjson-kole…

    6a0ea81
  11. clin1234
    added a commit that references this issue on Apr 16, 2026

    pythongh-144270: Make SubElement parent and tag positional-only (pyth…

    badd7fd
  12. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-144270: Make SubElement parent and tag positional-only (pyth…

    cbeb824
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.