-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-127787: refactor helpers for PyUnicodeErrorObject
internal interface
#127789
base: main
Are you sure you want to change the base?
gh-127787: refactor helpers for PyUnicodeErrorObject
internal interface
#127789
Conversation
- Unify `get_unicode` and `get_string` in a single function. - Allow to retrieve the underlying `object` attribute and its size in one round. - Use a common implementation for the following functions: - `PyUnicode{Decode,Encode}Error_GetEncoding` - `PyUnicode{Decode,Encode,Translate}Error_GetObject` - `PyUnicode{Decode,Encode,Translate}Error_{Get,Set}Reason` - `PyUnicode{Decode,Encode,Translate}Error_{Get,Set}{Start,End}`
@encukou I've designed a NVM: just removing the parameter. It's easier to make the check |
@encukou A little implementation question. Do you think it's preferrable to have PyObject *
PyUnicodeEncodeError_GetEncoding(PyObject *self)
{
int rc = check_unicode_error_type(self, "UnicodeEncodeError");
return rc < 0 ? NULL : unicode_error_get_encoding_impl(self);
} with int rc = check_unicode_error_type(self, expect_type); Unless I use generating maocrs, I'll end up either duplicating the |
Unify
get_unicode
andget_string
in a single function.Allow to retrieve the underlying
object
attribute, its size and its start and end indices in one round.Use a common implementation for the following functions:
PyUnicode{Decode,Encode}Error_GetEncoding
PyUnicode{Decode,Encode,Translate}Error_GetObject
PyUnicode{Decode,Encode,Translate}Error_{Get,Set}Reason
PyUnicode{Decode,Encode,Translate}Error_{Get,Set}{Start,End}
Note that there are some cosmetic changes here and there (in the naming of parameters) but these are essentially in prevision of #127694 in order to reduce the conflicts I'll need to solve (there will be conflicts probably but ideally, I want them to be minimal).
I've moved all helpers before the public API. I could move them inbetween but I felt that it's cleaner that way (it also allowed me to put double blank lines between functions a bit more easily).
PyUnicodeError
internal C helpers #127787