You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clean up internal callers of PyUnicode_AsASCIIString #15317
Many of the C functions in numpy have code that is something like:
PyObject*foo(PyObject*obj) {
if (PyUnicode_Check(obj)) {
/* accept unicode input */PyObject*obj_bytes=PyUnicode_AsASCIIString(obj);
if (obj_bytes==NULL) {
returnNULL;
}
PyObject*ret=foo(obj_bytes);
Py_DECREF(obj_bytes);
}
char*str=NULL;
Py_ssize_tlength=0;
if (PyBytes_AsStringAndSize(obj, &str, &length) <0) {
returnNULL;
}
// work with bytes
}
This construction means they raise UnicodeEncodeError for some illegal inputs, which is often less useful than the message would normally be
It would be better to work with the unicode objects directly, by copying the approach taken in the C code changes in #15261, notably these lines and these lines.
Activity
MAINT: parse nditer flags as unicode directly (numpygh-15317)
MAINT: parse nditer flags as unicode directly (numpygh-15317)
MAINT: parse nditer flags as unicode directly (numpygh-15317)
MAINT: parse nditer flags as unicode directly (gh-15317) (#32232)
MAINT: parse ndarray.flags keys as unicode directly (numpygh-15317)
MAINT: parse ndarray.flags keys as unicode directly (numpygh-15317)
MAINT: parse ndarray.flags keys as unicode directly (numpygh-15317)
MAINT: parse ndarray.flags keys as unicode directly (gh-15317) (#32305)
MAINT: parse dtype endian as unicode directly (numpygh-15317)
MAINT: parse dtype endian as unicode directly (numpygh-15317)
MAINT: parse dtype endian as unicode directly (gh-15317) (#32353)