Title: Incorrect handling of `start` and `end` values in `codecs` error handlers · Issue #126004 · python/cpython · GitHub
Open Graph Title: Incorrect handling of `start` and `end` values in `codecs` error handlers · Issue #126004 · python/cpython
X Title: Incorrect handling of `start` and `end` values in `codecs` error handlers · Issue #126004 · python/cpython
Description: Crash report What happened? ./python -c "import codecs; codecs.xmlcharrefreplace_errors(UnicodeEncodeError('bad', '', 0, 1, 'reason'))" python: ./Include/cpython/unicodeobject.h:339: PyUnicode_READ_CHAR: Assertion `index >= 0' failed. Ab...
Open Graph Description: Crash report What happened? ./python -c "import codecs; codecs.xmlcharrefreplace_errors(UnicodeEncodeError('bad', '', 0, 1, 'reason'))" python: ./Include/cpython/unicodeobject.h:339: PyUnicode_READ...
X Description: Crash report What happened? ./python -c "import codecs; codecs.xmlcharrefreplace_errors(UnicodeEncodeError('bad', '', 0, 1, 'reason'))" python: ./Include/cpython/u...
Opengraph URL: https://github.com/python/cpython/issues/126004
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect handling of `start` and `end` values in `codecs` error handlers","articleBody":"# Crash report\r\n\r\n### What happened?\r\n\r\n```py\r\n./python -c \"import codecs; codecs.xmlcharrefreplace_errors(UnicodeEncodeError('bad', '', 0, 1, 'reason'))\"\r\npython: ./Include/cpython/unicodeobject.h:339: PyUnicode_READ_CHAR: Assertion `index \u003e= 0' failed.\r\nAborted (core dumped)\r\n```\r\n\r\n```py\r\n./python -c \"import codecs; codecs.backslashreplace_errors(UnicodeDecodeError('utf-8', b'00000', 9, 2, 'reason'))\"\r\nTraceback (most recent call last):\r\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\r\nSystemError: Negative size passed to PyUnicode_New\r\n```\r\n\r\n```py\r\n./python -c \"import codecs; codecs.replace_errors(UnicodeTranslateError('000', 1, -7, 'reason'))\"\r\npython: Python/codecs.c:743: PyCodec_ReplaceErrors: Assertion `PyUnicode_KIND(res) == PyUnicode_2BYTE_KIND' failed.\r\nAborted (core dumped)\r\n```\r\n\r\nSee https://github.com/python/cpython/issues/123378 for the root cause. Since we are still wondering how to fix the getters and setters, I suggest we first fix the crash by adding the checks inside at the handler's level (for now). I'm not sure if the handler itself is handling corner cases correctly as well. \r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-127680\r\n* gh-127674\r\n* gh-127675\r\n* gh-127676\r\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/picnixz","@type":"Person","name":"picnixz"},"datePublished":"2024-10-26T11:28:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/126004/cpython/issues/126004"}
| 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:99bd5727-6323-a674-6180-84381a78d52a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B414:27340E:5F6544:7D91CF:696B72D2 |
| html-safe-nonce | a1750d7bd003a8ee1db15d688e82c3ef7cbd2d946978548888b585d216e05712 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDE0OjI3MzQwRTo1RjY1NDQ6N0Q5MUNGOjY5NkI3MkQyIiwidmlzaXRvcl9pZCI6IjUxODI2NTk2Mjk2NTYyNzM2MTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 16c98dfd606116ffaac2e8a051fbd52cee0e279306751879ae529cce08cf912e |
| hovercard-subject-tag | issue:2615794320 |
| 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/126004/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a51da691a37c7c12acac2a497096cd2a72d4f9cb1a5246396b38fa59714d5dd4/python/cpython/issues/126004 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a51da691a37c7c12acac2a497096cd2a72d4f9cb1a5246396b38fa59714d5dd4/python/cpython/issues/126004 |
| og:image:alt | Crash report What happened? ./python -c "import codecs; codecs.xmlcharrefreplace_errors(UnicodeEncodeError('bad', '', 0, 1, 'reason'))" python: ./Include/cpython/unicodeobject.h:339: PyUnicode_READ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | picnixz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width