This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jankratochvil
Recipients dmalcolm, jankratochvil
Date 2012-05-29.19:56:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1338321412.45.0.331737203349.issue14956@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-05-29 19:56:52jankratochvilsetrecipients: + jankratochvil, dmalcolm
2012-05-29 19:56:52jankratochvilsetmessageid: <1338321412.45.0.331737203349.issue14956@psf.upfronthosting.co.za>
2012-05-29 19:56:51jankratochvillinkissue14956 messages
2012-05-29 19:56:51jankratochvilcreate