From: Nick Coghlan Date: Sun, 15 Nov 2009 22:36:47 +0000 (+0000) Subject: Issue #7328: don't corrupt sys.path when running pydoc with the -m switch X-Git-Tag: v2.7a1~98 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11db64e5fd029a2e4db8e9d3c6c4676b410afc72;p=python 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 57071a1506..7da75b65bf 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 2f55a6786d..041f2a7723 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -429,6 +429,8 @@ Core and Builtins Library ------- +- Issue #7328: pydoc no longer corrupts sys.path when run with the '-m' switch + - Issue #2054: ftplib now provides an FTP_TLS class to do secure FTP using TLS or SSL. Patch by Giampaolo Rodola'.