René's URL Explorer Experiment


Title: ElementTree: itertext() and tostring(method="text") lose the text of elements whose tag is a QName · Issue #161809 · python/cpython · GitHub

Open Graph Title: ElementTree: itertext() and tostring(method="text") lose the text of elements whose tag is a QName · Issue #161809 · python/cpython

X Title: ElementTree: itertext() and tostring(method="text") lose the text of elements whose tag is a QName · Issue #161809 · python/cpython

Description: Bug report Bug description Element.itertext(), and therefore tostring(..., method="text"), skips elements whose tag is not a str, in order to leave out comments and processing instructions. The same check also matches QName tags, so thei...

Open Graph Description: Bug report Bug description Element.itertext(), and therefore tostring(..., method="text"), skips elements whose tag is not a str, in order to leave out comments and processing instructions. The sam...

X Description: Bug report Bug description Element.itertext(), and therefore tostring(..., method="text"), skips elements whose tag is not a str, in order to leave out comments and processing instruction...

Opengraph URL: https://github.com/python/cpython/issues/161809

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ElementTree: itertext() and tostring(method=\"text\") lose the text of elements whose tag is a QName","articleBody":"### Bug report\n\n### Bug description\n\n`Element.itertext()`, and therefore `tostring(..., method=\"text\")`, skips elements whose tag is not a `str`, in order to leave out comments and processing instructions. The same check also matches `QName` tags, so their text disappears, even though the tree serializes to XML with all of its text:\n\n```python\nimport xml.etree.ElementTree as ET\n\nroot = ET.Element(ET.QName(\"http://example.com/ns\", \"doc\"))\nroot.text = \"hello \"\nb = ET.SubElement(root, \"b\"); b.text = \"world\"; b.tail = \"!\"\ni = ET.SubElement(root, ET.QName(\"http://example.com/ns\", \"i\")); i.text = \"QTEXT\"\n\nET.tostring(root, encoding=\"unicode\")\n# '\u003cns0:doc xmlns:ns0=\"http://example.com/ns\">hello \u003cb>world\u003c/b>!\u003cns0:i>QTEXT\u003c/ns0:i>\u003c/ns0:doc>'\nlist(root.itertext())\n```\n\n| `list(root.itertext())` | C accelerator | pure Python |\n|---|---|---|\n| 3.12.16 | `['hello ', 'world', '!', 'QTEXT']` | `[]` |\n| 3.13.18, 3.14.10 | `['world', '!']` | `[]` |\n\n`tostring(root, method=\"text\", encoding=\"unicode\")` gives `'hello world!QTEXT'` with C on 3.12, `'world!'` with C on 3.13 and 3.14, and `''` with the pure-Python implementation.\n\n**Cause.** Both implementations skip on \"tag is not a `str`\": Python has `if not isinstance(tag, str) and tag is not None: return` in `Element.itertext()`, and C has `if (elem->tag != Py_None && !PyUnicode_Check(elem->tag))` in `elementiter_next()`. The C check came with the fix for gh-149571 (GH-149929), which made C skip comments and processing instructions like Python does; `QName` tags were not considered there. That is why C on 3.13 and 3.14 now drops the text of `QName` elements. It still yields their children's text and tails, while Python returns nothing for the whole subtree.\n\n\n\n### CPython versions tested on:\n\n3.12, 3.13, 3.14, CPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-161878\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/ines-besrour","@type":"Person","name":"ines-besrour"},"datePublished":"2026-11-11T14:06:01Z","url":"https://github.com/python/cpython/issues/161809"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0597d710-fa5d-120c-a3d5-ac3fcd3e75b4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC672:8AE25:17195E7:1E98541:6B02086C
html-safe-nonce4706c844187533d451ce4309d7ddf2909d546617afecd30888653c58c111559d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjcyOjhBRTI1OjE3MTk1RTc6MUU5ODU0MTo2QjAyMDg2QyIsInZpc2l0b3JfaWQiOiI4Njk1MDkyMTI2MzkzOTYwNTU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac28a0cd0ab5d69377b994564f6f3ddcdb4502c937796c227d3f786b3373f8af78
hovercard-subject-tagissue:6330156069
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/161809/issue_layout
twitter:imagehttps://opengraph.githubassets.com/83f770b3f28cdb3ec095eb77986eadac9a24391eac3705092320d546ba20db03/python/cpython/issues/161809
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/83f770b3f28cdb3ec095eb77986eadac9a24391eac3705092320d546ba20db03/python/cpython/issues/161809
og:image:altBug report Bug description Element.itertext(), and therefore tostring(..., method="text"), skips elements whose tag is not a str, in order to leave out comments and processing instructions. The sam...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameines-besrour
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/161809#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F161809
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F161809
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/161809
Reloadhttps://github.com/python/cpython/issues/161809
Reloadhttps://github.com/python/cpython/issues/161809
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/161809
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/161809
#161878https://github.com/python/cpython/pull/161878
ElementTree: itertext() and tostring(method="text") lose the text of elements whose tag is a QNamehttps://github.com/python/cpython/issues/161809#top
#161878https://github.com/python/cpython/pull/161878
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-XMLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-XML%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/ines-besrour
ines-besrourhttps://github.com/ines-besrour
on Nov 11, 2026https://github.com/python/cpython/issues/161809#issue-6330156069
gh-149571https://github.com/python/cpython/issues/149571
GH-149929https://github.com/python/cpython/pull/149929
gh-161809: Fix itertext() skipping elements with QName tags #161878https://github.com/python/cpython/pull/161878
ines-besrourhttps://github.com/ines-besrour
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Nov 11, 2026https://github.com/python/cpython/issues/161809#event-35805926778
picnixzhttps://github.com/picnixz
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-XMLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-XML%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on Nov 11, 2026https://github.com/python/cpython/issues/161809#event-35807525060
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Nov 11, 2026https://github.com/python/cpython/issues/161809#issuecomment-6798376334
@serhiy-storchakahttps://github.com/serhiy-storchaka
Aareevshttps://github.com/Aareevs
on Nov 13, 2026https://github.com/python/cpython/issues/161809#event-36019670630
pythongh-161809: Skip callable tags in itertext() instead of non-str …https://github.com/Aareevs/cpython/commit/5cb5b9572c75acf63f5369110f46a3e6c36e9247
pythongh-161809https://github.com/python/cpython/issues/161809
5cb5b95https://github.com/Aareevs/cpython/commit/5cb5b9572c75acf63f5369110f46a3e6c36e9247
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/161809
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/161809
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
topic-XMLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-XML%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.