[issue24534] disable executing code in .pth files

2015-07-02 Thread Paul Moore
Paul Moore added the comment: On 30 June 2015 at 23:30, M.-A. Lemburg m...@egenix.com wrote: I don't remember the details of why this feature was added, but can imagine that it was supposed to enable installation of new importers via .pth files. I don't know for certain if this feature was

[issue24534] disable executing code in .pth files

2015-07-02 Thread Eric Snow
Eric Snow added the comment: Note that the idea of replacing .pth files came up a couple years ago: https://mail.python.org/pipermail/import-sig/2013-July/000645.html That proposal didn't go anywhere basically because there were more important things to work on. :) --

[issue24534] disable executing code in .pth files

2015-07-02 Thread Eric Snow
Eric Snow added the comment: FYI, support for .pth has been around since at least Python 2.0. However, support for imports in .pth files was added in 2.1: changeset: 15815:868d2acf745808c9033f57cd5829d97a69ecf56e branch: legacy-trunk user:Martin v. Löwis mar...@v.loewis.de

[issue24534] disable executing code in .pth files

2015-06-30 Thread Christian Heimes
Changes by Christian Heimes li...@cheimes.de: -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24534 ___ ___

[issue24534] disable executing code in .pth files

2015-06-30 Thread Nick Coghlan
Nick Coghlan added the comment: As others have noted, we're not going to change this default in the standard CPython executable (due to the degree of disruption involved), and the -S and -I switches already effectively turn it off (by disabling site module processing entirely) However, it

[issue24534] disable executing code in .pth files

2015-06-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 30.06.2015 20:52, Min RK wrote: Thanks for the feedback, I thought it might be a long shot. I will go back to removing the *use* of the feature everywhere I can find it, since it is so problematic and rarely, if ever, desirable. Could you please

[issue24534] disable executing code in .pth files

2015-06-30 Thread Min RK
Min RK added the comment: Could you please post an example of where the feature is problematic ? setuptools/easy_install is the major one, which effectively does `sys.path[:0] = pth_contents`, breaking import priority. This has been known to result in adding

[issue24534] disable executing code in .pth files

2015-06-30 Thread Min RK
Min RK added the comment: Thanks for the feedback, I thought it might be a long shot. I will go back to removing the *use* of the feature everywhere I can find it, since it is so problematic and rarely, if ever, desirable. it's an essential feature that has been documented for a very long

[issue24534] disable executing code in .pth files

2015-06-30 Thread Min RK
Min RK added the comment: Just because a feature can be misused doesn't make it a bad feature. That's fair. I'm just not aware of any uses of this feature that aren't misuses, hence the patch. Perhaps you could submit a fix for this to the setuptools maintainers instead. Yes, that's

Re: [issue24534] disable executing code in .pth files

2015-06-30 Thread M.-A. Lemburg
On 01.07.2015 00:16, Min RK wrote: Just because a feature can be misused doesn't make it a bad feature. That's fair. I'm just not aware of any uses of this feature that aren't misuses, hence the patch. I don't remember the details of why this feature was added, but can imagine that it was

[issue24534] disable executing code in .pth files

2015-06-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 30.06.2015 22:49, Min RK wrote: Could you please post an example of where the feature is problematic ? setuptools/easy_install is the major one, which effectively does `sys.path[:0] = pth_contents`, breaking import priority. This has been known

[issue24534] disable executing code in .pth files

2015-06-29 Thread STINNER Victor
STINNER Victor added the comment: The attached patch removes support for executing code in .pth files This change will basically break all Python applications. Don't do that. If you believe that we can smoothly move to a world without .pth files, you should propose an overall plan, step by

[issue24534] disable executing code in .pth files

2015-06-29 Thread R. David Murray
R. David Murray added the comment: I'm guessing this feature has been around too long and is used in too many ways to remove. I believe it is effectively disabled by -I (if it is not, that would be a valid feature request). However, since setuptools was the pioneer in this area, if

[issue24534] disable executing code in .pth files

2015-06-29 Thread Ned Deily
Changes by Ned Deily n...@acm.org: -- nosy: +brett.cannon, eric.snow, ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24534 ___ ___

[issue24534] disable executing code in .pth files

2015-06-29 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 29.06.2015 21:30, Min RK wrote: .pth files currently allow execution of arbitrary code, triggered by lines starting with `import`. This is a rarely understood, and often misbehaving feature. easy_install has used this feature to ensure that its

[issue24534] disable executing code in .pth files

2015-06-29 Thread Tim Smith
Tim Smith added the comment: In Homebrew we occasionally use .pth files to call site.addsitedir. This is useful when we want to add a directory to sys.path that contains .pth files that also need to be processed (for example, when adding a directory to sys.path that contains namespace

[issue24534] disable executing code in .pth files

2015-06-29 Thread Min RK
New submission from Min RK: .pth files currently allow execution of arbitrary code, triggered by lines starting with `import`. This is a rarely understood, and often misbehaving feature. easy_install has used this feature to ensure that its packages are highest priority (even higher than