summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2009-11-15 23:04:33 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2009-11-15 23:04:33 (GMT)
commit106274b430ac0112b45bea11a8fb99e185abb252 (patch)
tree26e523276214a6a1d94609902c1e9a94bbab725e /Lib/pydoc.py
parent9ea6f632736d0fbe97d7b5aca7d6291a6c1743fd (diff)
downloadcpython-106274b430ac0112b45bea11a8fb99e185abb252.zip
cpython-106274b430ac0112b45bea11a8fb99e185abb252.tar.gz
cpython-106274b430ac0112b45bea11a8fb99e185abb252.tar.bz2
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 ........
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 68771c9..28d3bb8 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -2249,11 +2249,13 @@ def cli():
import getopt
class BadUsage(Exception): 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')