mirror of https://github.com/python/cpython
Issue #7328: don't corrupt sys.path when running pydoc with the -m switch
This commit is contained in:
parent
ccd5e02d2b
commit
11db64e5fd
12
Lib/pydoc.py
12
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')
|
||||
|
|
Loading…
Reference in New Issue