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
In python 3.12 the Py_FileSystemDefaultEncoding global variable has been
deprecated. This was used in combination with a "et" PyArgs format
specifier to get a raw C string with the encoded bytes for the input
filename.
This commit replaces the usage of Py_FileSystemDefaultEncoding with a
manual call to PyUnicode_EncodeFSDefault instead (only within
b_do_dlopen_posix). This function requires a unicode object as an input,
and therefore we now need to accept the argument with the "U" format
specifier. While this is a departure from the "et" specifier, which
accepts not only strings, but also bytes and bytearrays, this is
inconsequential, since the higher-level cffi API already ensures we get
a string object here. Moreover, we were already calling PyUnicode_AsUTF8
on it, which would have failed if we received bytes. Thus this new
constrain is fine.
With this change there's no need anymore to keep around the raw C
pointer in the b_do_dlopen() function, and it can be moved down to
b_do_dlopen_posix(), where it doensn't need to be freed (as it's now
taken from a PyBytes object via PyBytes_AsString). We can also now
remove the unnecessary "s" variable since the filename_unicode variable
(previously used only in the win32 case, now always) holds the same
value.
0 commit comments