This is because PyUnicode_DecodeFSDefaultAndSize calls _PyInterpreterState_GET_UNSAFE(), which already documents the potential NULL return value.
/* Get the current interpreter state.
The macro is unsafe: it does not check for error and it can return NULL.
The caller must hold the GIL.
See also _PyInterpreterState_Get()
and _PyGILState_GetInterpreterStateUnsafe(). */
#define _PyInterpreterState_GET_UNSAFE() (_PyThreadState_GET()->interp)
> Python has a *very large* C API. It doesn't seem worth it to me to modify every single Python function to detect when the API is misused.
Understood, happy for this to be closed. Aware that I was misusing the API :-) |