From: Nick Coghlan Date: Sun, 15 Nov 2009 22:58:27 +0000 (+0000) Subject: Merged revisions 76312 via svnmerge from X-Git-Tag: v2.6.5rc1~352 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29d5bb19c8a38c51e7b9c8f30d3c9ea0f5f5b09e;p=python Merged revisions 76312 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76312 | nick.coghlan | 2009-11-16 08:36:47 +1000 (Mon, 16 Nov 2009) | 1 line Issue #7328: don't corrupt sys.path when running pydoc with the -m switch ........ --- diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 9920fcb2de..4cf9066caa 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -2254,11 +2254,13 @@ def cli(): import getopt class BadUsage: pass - # Scripts don't get the current directory in their path by default. - scriptdir = os.path.dirname(sys.argv[0]) - if scriptdir in sys.path: - sys.path.remove(scriptdir) - sys.path.insert(0, '.') + # Scripts don't get the current directory in their path by default + # unless they are run with the '-m' switch + if '' not in sys.path: + scriptdir = os.path.dirname(sys.argv[0]) + if scriptdir in sys.path: + sys.path.remove(scriptdir) + sys.path.insert(0, '.') try: opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w') diff --git a/Misc/NEWS b/Misc/NEWS index a8eeaf200d..aecf5ca589 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -26,6 +26,8 @@ Core and Builtins Library ------- +- Issue #7328: pydoc no longer corrupts sys.path when run with the '-m' switch + - Issue #7318: multiprocessing now uses a timeout when it fails to establish a connection with another process, rather than looping endlessly. The default timeout is 20 seconds, which should be amply sufficient for