cpython: bd1af1a97c2e (original) (raw)
Mercurial > cpython
changeset 100875:bd1af1a97c2e
Issue #26587: Allow .pth files to specify file paths as well as directories. Thanks to Wolfgang Langner for the bug report and initial version of the patch. [#26587]
Brett Cannon brett@python.org | |
---|---|
date | Fri, 08 Apr 2016 15:04:28 -0700 |
parents | d214b30e8ef0 |
children | 94d5c57ee835 |
files | Doc/whatsnew/3.6.rst Lib/site.py Lib/test/test_site.py Misc/ACKS Misc/NEWS |
diffstat | 5 files changed, 22 insertions(+), 10 deletions(-)[+] [-] Doc/whatsnew/3.6.rst 8 Lib/site.py 18 Lib/test/test_site.py 2 Misc/ACKS 1 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -251,6 +251,14 @@ Previously, names of properties and slot
an instance were excluded. (Contributed by Martin Panter in :issue:25590
.)
+site
+----
+
+When specifying paths to add to :attr:sys.path
in a .pth
file,
+you may now specify file paths on top of directories (e.g. zip files).
+(Contributed by Wolfgang Langner in :issue:26587
).
+
+
telnetlib
---------
--- a/Lib/site.py +++ b/Lib/site.py @@ -131,13 +131,13 @@ def removeduppaths(): def _init_pathinfo():
if os.path.isdir(dir):[](#l2.13)
dir, dircase = makepath(dir)[](#l2.14)
d.add(dircase)[](#l2.15)
if os.path.exists(item):[](#l2.16)
_, itemcase = makepath(item)[](#l2.17)
return d @@ -150,9 +150,9 @@ def addpackage(sitedir, name, known_path """ if known_paths is None: known_paths = _init_pathinfo()d.add(itemcase)[](#l2.18) except TypeError:[](#l2.19) continue[](#l2.20)
reset = 1[](#l2.26)
reset = 0[](#l2.29)
@@ -190,9 +190,9 @@ def addsitedir(sitedir, known_paths=None 'sitedir'""" if known_paths is None: known_paths = _init_pathinfo()
reset = 1[](#l2.38)
reset = 0[](#l2.41)
sitedir, sitedircase = makepath(sitedir) if not sitedircase in known_paths: sys.path.append(sitedir) # Add path componentreset = False[](#l2.42)
--- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -75,7 +75,7 @@ class HelperFunctionsTests(unittest.Test def test_init_pathinfo(self): dir_set = site._init_pathinfo() for entry in [site.makepath(path)[1] for path in sys.path
if path and os.path.isdir(path)]:[](#l3.7)
if path and os.path.exists(path)]:[](#l3.8) self.assertIn(entry, dir_set,[](#l3.9) "%s from sys.path not found in set returned "[](#l3.10) "by _init_pathinfo(): %s" % (entry, dir_set))[](#l3.11)
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -815,6 +815,7 @@ Torsten Landschoff Tino Lange Glenn Langford Andrew Langmead +Wolfgang Langner Detlef Lannert Soren Larsen Amos Latteier
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -237,6 +237,9 @@ Core and Builtins Library ------- +- Issue #26587: the site module now allows .pth files to specify files to be