[issue36386] segfault on PyUnicode_DecodeFSDefaultAndSize for uninitialized Py

2019-03-21 Thread STINNER Victor
STINNER Victor added the comment: > This is because PyUnicode_DecodeFSDefaultAndSize calls > _PyInterpreterState_GET_UNSAFE(), which already documents the potential NULL > return value. _PyInterpreterState_GET_UNSAFE() is preferred over other functions getting the interpreter for best perf

[issue36386] segfault on PyUnicode_DecodeFSDefaultAndSize for uninitialized Py

2019-03-21 Thread anthony shaw
anthony shaw added the comment: 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

[issue36386] segfault on PyUnicode_DecodeFSDefaultAndSize for uninitialized Py

2019-03-21 Thread STINNER Victor
STINNER Victor added the comment: > I'm expecting a "this is not a bug, why would the interpreter not be > initialized", this is not a bug, why would the interpreter not be initialized, as documented at: https://docs.python.org/dev/c-api/init.html > but it would be nice to get a friendly er

[issue36386] segfault on PyUnicode_DecodeFSDefaultAndSize for uninitialized Py

2019-03-21 Thread SilentGhost
Change by SilentGhost : -- nosy: +vstinner type: -> crash ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue36386] segfault on PyUnicode_DecodeFSDefaultAndSize for uninitialized Py

2019-03-21 Thread anthony shaw
anthony shaw added the comment: I'm expecting a "this is not a bug, why would the interpreter not be initialized", but it would be nice to get a friendly error message since this is a public API. IF so, am also happy to submit a PR with a fix -- _

[issue36386] segfault on PyUnicode_DecodeFSDefaultAndSize for uninitialized Py

2019-03-21 Thread anthony shaw
anthony shaw added the comment: This applies to PyUnicode_EncodeFSDefault as well, it has the same issue -- ___ Python tracker ___

[issue36386] segfault on PyUnicode_DecodeFSDefaultAndSize for uninitialized Py

2019-03-20 Thread anthony shaw
New submission from anthony shaw : If for whatever reason, Py_Initialize() has not been run or failed to run, any call to Py_CompileStringFlags will call PyUnicode_DecodeFSDefault and the reference to interp will be NULL. There is currently no null reference check in PyUnicode_DecodeFSDefault