Title: Incorrect handling of negative `start` values on `PyUnicodeErrorObject` · Issue #123378 · python/cpython · GitHub
Open Graph Title: Incorrect handling of negative `start` values on `PyUnicodeErrorObject` · Issue #123378 · python/cpython
X Title: Incorrect handling of negative `start` values on `PyUnicodeErrorObject` · Issue #123378 · python/cpython
Description: Bug report Bug description: Found when implementing #123343. We have: int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { Py_ssize_t size; PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)->object, "object"); if...
Open Graph Description: Bug report Bug description: Found when implementing #123343. We have: int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { Py_ssize_t size; PyObject *obj = get_unicode(((PyUnicodeE...
X Description: Bug report Bug description: Found when implementing #123343. We have: int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { Py_ssize_t size; PyObject *obj = get_unicode(((PyUnicodeE...
Opengraph URL: https://github.com/python/cpython/issues/123378
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect handling of negative `start` values on `PyUnicodeErrorObject`","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nFound when implementing #123343. We have:\r\n\r\n```C\r\nint\r\nPyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)\r\n{\r\n Py_ssize_t size;\r\n PyObject *obj = get_unicode(((PyUnicodeErrorObject *)exc)-\u003eobject,\r\n \"object\");\r\n if (!obj)\r\n return -1;\r\n *start = ((PyUnicodeErrorObject *)exc)-\u003estart;\r\n size = PyUnicode_GET_LENGTH(obj);\r\n if (*start\u003c0)\r\n *start = 0; /*XXX check for values \u003c0*/\r\n if (*start\u003e=size)\r\n *start = size-1;\r\n Py_DECREF(obj);\r\n return 0;\r\n}\r\n```\r\n\r\nThe line `*start = size-1` might set `start` to `-1` when `start = 0`, in which case this leads to assertion failures when the index is used normally.\r\n\r\n\r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-124935\r\n* gh-125098\r\n* gh-125099\r\n* gh-123380\r\n* gh-127739\r\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/picnixz","@type":"Person","name":"picnixz"},"datePublished":"2024-08-27T07:05:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/123378/cpython/issues/123378"}
| 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:ccb181fe-9fb1-c82e-b581-9f6afbe76f32 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B512:C9EB4:19B8070:2162554:696B30D6 |
| html-safe-nonce | 576d635d95dc3eb8d9f1bea79c5e85f2a7666f7efb5512c916c03276d6948b81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTEyOkM5RUI0OjE5QjgwNzA6MjE2MjU1NDo2OTZCMzBENiIsInZpc2l0b3JfaWQiOiI1NDExNDQwNjgzNDA0NDM5NzY2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2992ab327cc2c5f04c99807070c954a37de334dcb480ec47a900c3021582eca2 |
| hovercard-subject-tag | issue:2488477522 |
| 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/123378/issue_layout |
| twitter:image | https://opengraph.githubassets.com/12bba80061f831225eeeb817c5568c0b79f33f017b3433647ecf20aacea1d064/python/cpython/issues/123378 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/12bba80061f831225eeeb817c5568c0b79f33f017b3433647ecf20aacea1d064/python/cpython/issues/123378 |
| og:image:alt | Bug report Bug description: Found when implementing #123343. We have: int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start) { Py_ssize_t size; PyObject *obj = get_unicode(((PyUnicodeE... |
| 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