Feature or enhancement
Proposal:
Some helpers make the realization of #126004 a bit harder as we end up with many duplicated code. In order to make the related PRs and #127694 smoother, I suggest refactoring the following helpers:
- Unify
get_unicode and get_string as a single as_unicode_error_attribute.
- Allow to retrieve the underlying
object attribute and its size in one function, say get_unicode_error_object_and_size. This is typically useful for unifying
- The
PyUnicode{Encode,Decode,Translate}Error_GetObject public functions can use a common implementation unicode_error_get_object_impl. Since this depends on the underlying object type, the implementation function would take a flag as a parameter to indicate whether it's a bytes or a string.
- All
PyUnicode{Encode,Decode}Error_GetEncoding public functions can use a common implementation unicode_error_get_encoding_impl. The encoding is always a string.
- All
PyUnicode{Encode,Decode,Translate}Error_{Get,Set}Reason public functions can use a common implementation unicode_error_{get,set}_reason_impl. The reason is always a string.
- All
PyUnicode{Encode,Decode,Translate}_{Get,Set}{Start,End} public functions can use a common implementation unicode_error_{get,set}_{start,end}_impl. Since this depends on the underlying object type, the implementation function would take a flag as a parameter to indicate whether it's a bytes or a string.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
#127674 (comment)
Linked PRs
Feature or enhancement
Proposal:
Some helpers make the realization of #126004 a bit harder as we end up with many duplicated code. In order to make the related PRs and #127694 smoother, I suggest refactoring the following helpers:
get_unicodeandget_stringas a singleas_unicode_error_attribute.objectattribute and its size in one function, sayget_unicode_error_object_and_size. This is typically useful for unifyingPyUnicode{Encode,Decode,Translate}Error_GetObjectpublic functions can use a common implementationunicode_error_get_object_impl. Since this depends on the underlyingobjecttype, the implementation function would take a flag as a parameter to indicate whether it's a bytes or a string.PyUnicode{Encode,Decode}Error_GetEncodingpublic functions can use a common implementationunicode_error_get_encoding_impl. The encoding is always a string.PyUnicode{Encode,Decode,Translate}Error_{Get,Set}Reasonpublic functions can use a common implementationunicode_error_{get,set}_reason_impl. The reason is always a string.PyUnicode{Encode,Decode,Translate}_{Get,Set}{Start,End}public functions can use a common implementationunicode_error_{get,set}_{start,end}_impl. Since this depends on the underlyingobjecttype, the implementation function would take a flag as a parameter to indicate whether it's a bytes or a string.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
#127674 (comment)
Linked PRs
PyUnicodeErrorObjectinternal interface #127789_PyUnicodeError_GetParams#128980