Title: Remove leftover bytes support from _elementtree · Issue #157366 · python/cpython · GitHub
Open Graph Title: Remove leftover bytes support from _elementtree · Issue #157366 · python/cpython
X Title: Remove leftover bytes support from _elementtree · Issue #157366 · python/cpython
Description: Bug report Modules/_elementtree.c still has four places which accept bytes. They are the result of improper translation of the PyString C API used in Python 2 to PyBytes (72b710a). The Python implementation of xml.etree.ElementTree accep...
Open Graph Description: Bug report Modules/_elementtree.c still has four places which accept bytes. They are the result of improper translation of the PyString C API used in Python 2 to PyBytes (72b710a). The Python imple...
X Description: Bug report Modules/_elementtree.c still has four places which accept bytes. They are the result of improper translation of the PyString C API used in Python 2 to PyBytes (72b710a). The Python imple...
Opengraph URL: https://github.com/python/cpython/issues/157366
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remove leftover bytes support from _elementtree","articleBody":"# Bug report\n\n`Modules/_elementtree.c` still has four places which accept `bytes`. They are the result of improper translation of the `PyString` C API used in Python 2 to `PyBytes` (72b710a5961). The Python implementation of `xml.etree.ElementTree` accepts only `str` there, and gh-72424 declared bytes unsupported.\n\n1. `checkpath()` checks a bytes path for XPath characters, so `find()`, `findall()` and `findtext()` with a bytes path return `None`/`[]`/`''` instead of raising `TypeError` like `iterfind()` and the Python implementation.\n2. `Element.iter()` treats `b'*'` as a wildcard.\n3. `XMLParser._setevents()` accepts bytes event names, like `b'start'`. The Python implementation raises `ValueError`; the events were documented as strings in gh-53503.\n4. `treebuilder_handle_data()` concatenates a one-byte `bytes` to a `bytes`. It is dead code: the parser always passes `str`.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-157367\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-09-12T15:48:54Z","url":"https://github.com/python/cpython/issues/157366"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1d58ccf4-c1fe-9784-9e2c-26568da3f733 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98CA:2A1EC8:F6898:1380CA:6B01EDD3 |
| html-safe-nonce | d9a3dd226b6f01fa84638755196daba2cd9fab171f8a413c620f11b23a1bbe99 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OENBOjJBMUVDODpGNjg5ODoxMzgwQ0E6NkIwMUVERDMiLCJ2aXNpdG9yX2lkIjoiODE0OTM4NDIxNjEwMzIxODY0MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd117e496ee7c4aea85cb8acbdd7f14de36b21c38d5e9458606b612477c60999 |
| hovercard-subject-tag | issue:5434340730 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/157366/issue_layout |
| twitter:image | https://opengraph.githubassets.com/51e0b7aef5d52c9969f1ec99beea8497132729b237464d99a8e42891cfed746a/python/cpython/issues/157366 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/51e0b7aef5d52c9969f1ec99beea8497132729b237464d99a8e42891cfed746a/python/cpython/issues/157366 |
| og:image:alt | Bug report Modules/_elementtree.c still has four places which accept bytes. They are the result of improper translation of the PyString C API used in Python 2 to PyBytes (72b710a). The Python imple... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width