Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Labels
stdlibStandard Library Python modules in the Lib/ directorytopic-XMLtype-bugAn unexpected behavior, bug, or error
@Timmmm

Description

@Timmmm

Bug report

Bug description:

This code runs fine on Python 3.13.7:

importxml.etree.ElementTreeasETx=ET.Element("x")ET.SubElement(x,0,parent="0")

However, Pyrightcorrectly detects a type error in theSubElement call.SubElement has this Python signature:

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

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

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

Whichdoes allow specifyingparent="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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp