[issue36196] sys.executable does not return python3 executable when using uwsgi

New submission from Joris VAN HOUTVEN <joris.vanhoutven@uhasselt.be>: when serving a Flask app with uwsgi, using `sys.executable` will provide you the path to your uwsgi executable, not your python executable. However, the docs specify that it should always return the python interpreter: https://docs.python.org/3/library/sys.html#sys.executable ---------- assignee: docs@python components: Documentation messages: 337190 nosy: Joris VAN HOUTVEN, docs@python priority: normal severity: normal status: open title: sys.executable does not return python3 executable when using uwsgi type: behavior _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36196> _______________________________________

Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: related uwsgi issue : https://github.com/unbit/uwsgi/issues/670 ---------- nosy: +xtreak _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36196> _______________________________________

Inada Naoki <songofacandy@gmail.com> added the comment: I don't think this is a documentation bug. They insert "uwsgi" to "sys.executable" manually. https://github.com/unbit/uwsgi/blob/3149df02ed443131c54ea6afb29fcbb0ed4d1139... #ifdef PYTHREE PyDict_SetItemString(sys_dict, "executable", PyUnicode_FromString(uwsgi.binary_path)); #else PyDict_SetItemString(sys_dict, "executable", PyString_FromString(uwsgi.binary_path)); #endif ---------- nosy: +inada.naoki _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36196> _______________________________________

Joris VAN HOUTVEN <joris.vanhoutven@uhasselt.be> added the comment: OK, so it is indeed uwsgi interfering with the sys.executable value. In the github pst Inada Naoki refers to: "uwsgi is your current python interpreter, as it links the libpython.so. Getting sys.executable is not possibile as there is no binary path hard-encoded in library by itself" So I suppose this issue can be closed here. I will comment on the uwsgi github. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36196> _______________________________________

Change by Inada Naoki <songofacandy@gmail.com>: ---------- resolution: -> fixed stage: -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36196> _______________________________________

Change by Inada Naoki <songofacandy@gmail.com>: ---------- resolution: fixed -> not a bug _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue36196> _______________________________________
participants (3)
-
Inada Naoki
-
Joris VAN HOUTVEN
-
Karthikeyan Singaravelan