mirror of https://github.com/python/cpython
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 ........
This commit is contained in:
parent
9ea6f63273
commit
106274b430
12
Lib/pydoc.py
12
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')
|
||||
|
|
Loading…
Reference in New Issue