New submission from Jan Kratochvil <jan.kratoch...@redhat.com>: People use custom Python builds setting PYTHONHOME and PYTHONPATH to these custom builds. This may be expected to break running system Python binary but it also unexpectedly breaks various applications which also embed Python:
$ echo foo >site.py; export PYTHONPATH=. $ gdb Traceback (most recent call last): File "./site.py", line 1, in <module> foo NameError: name 'foo' is not defined $ _ It is not obvious to the user who even already forgot about custom PYTHONPATH why GDB breaks. Standard Fedora applications may link with system libpython incompatible with the PYTHONHOME/PYTHONPATH files for the other Python version. Python does not keep the scripts too compatible across Python versions. This issues was discussed first for GDB upstream: [RFA] ignore PYTHONHOME environment variable. http://sourceware.org/ml/gdb-patches/2010-11/msg00328.html http://sourceware.org/ml/gdb-patches/2010-12/msg00214.html http://sourceware.org/ml/gdb-patches/2011-01/msg00307.html http://sourceware.org/ml/gdb-patches/2012-05/msg00710.html (first mail of the thread in each month) Then also in Fedora: https://fedorahosted.org/fesco/ticket/858 This Python issue would not be filed by the user if it gets resolved: Issue12140 Exactly the same problem exists for many other apps, yum for all $ echo foo >site.py; PYTHONPATH=. yum list bash Traceback (most recent call last): File "./site.py", line 1, in <module> foo NameError: name 'foo' is not defined $ _ Various proposal have been, applicable possibly in some combination together: * Ignore PYTHONHOME/PYTHONPATH for embedded applications. (dot) * Ignore PYTHONHOME, use only GDB_PYTHONHOME (if set). This proposal is not applicable for all applications in general. * Print warning if PYTHONHOME/PYTHONPATH is set. * Recover from Python startup failure and suppress the environment vars. or Recover from Python startup failure and disable the Python support, if possible. * Should the special care affect PYTHONHOME? Differently for PYTHONPATH? What about PYTHONVERBOSE and other PYTHON* settings? How should get PYTHONHOME/PYTHONPATH inherited into child processes, if any (debuggees in the GDB case). Another question is whether the behavior should be the same if upstream application has been linked with non-system libpython location. ---------- components: Interpreter Core messages: 161906 nosy: dmalcolm, jankratochvil priority: normal severity: normal status: open title: custom PYTHONPATH breaks Python-embedded apps type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14956> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com