GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-123378: fix some corner cases of `start` and `end` values in `PyUnicodeErrorObject` by picnixz · Pull Request #123380 · python/cpython Conversation
|
|
Thank you Victor for your review! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@serhiy-storchaka: Do you want to double check the fix?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit sad that we can't agree to fix the setters, but, if we're fixing the C getters, this is the way to go.
A few nitpicks:
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| static inline int | ||
| unicode_error_set_end_impl(PyObject *exc, Py_ssize_t end) | ||
| { | ||
| ((PyUnicodeErrorObject *)exc)->end = end; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
While you're here, could you add a type check before each cast?
assert(PyObject_TypeCheck(exc, (PyTypeObject*)&PyExc_UnicodeError));
Ideally, public API would raise TypeError on wrong types, but that change might be too big.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should we make a follow-up PR for adding assertions on the getters as well?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That would be great! Thank you for volunteering :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| static inline int | ||
| unicode_error_set_end_impl(PyObject *exc, Py_ssize_t end) | ||
| { | ||
| ((PyUnicodeErrorObject *)exc)->end = end; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That would be great! Thank you for volunteering :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Feel free to leave all the asserts to a follow-up PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Question: should we backport this to 3.12 and 3.13? it's both a feature and a bugfix in some sense but I feel it's more a bug fix even though it could change the behaviour of some code (hopefully, not too much...). The WDYT? By the way, I spotted some typos here and there. I'll correct them as part of a follow-up PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
If I understand correctly, it could only return -1 with an empty string, which isn't something one would typically get encoding errors for. Also, at this level you get a wrong value rather than a crash. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yup. (to be clear, it's the size that is being stored in In this case, subsequent calls usually lead to crashes because the C API assumes non-relative offsets in general.
Thanks, it's essentially to know whether the patches for codecs handlers will be backported or not (without the backport of this PR, the handlers would still be broken I think). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…re clamped (pythonGH-123380) Co-authored-by: Sergey B Kirpichev <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.