Kaydet (Commit) 11db64e5 authored tarafından Nick Coghlan's avatar Nick Coghlan

Issue #7328: don't corrupt sys.path when running pydoc with the -m switch

üst ccd5e02d
...@@ -2254,11 +2254,13 @@ def cli(): ...@@ -2254,11 +2254,13 @@ def cli():
import getopt import getopt
class BadUsage: pass class BadUsage: pass
# Scripts don't get the current directory in their path by default. # Scripts don't get the current directory in their path by default
scriptdir = os.path.dirname(sys.argv[0]) # unless they are run with the '-m' switch
if scriptdir in sys.path: if '' not in sys.path:
sys.path.remove(scriptdir) scriptdir = os.path.dirname(sys.argv[0])
sys.path.insert(0, '.') if scriptdir in sys.path:
sys.path.remove(scriptdir)
sys.path.insert(0, '.')
try: try:
opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w') opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w')
......
...@@ -429,6 +429,8 @@ Core and Builtins ...@@ -429,6 +429,8 @@ Core and Builtins
Library 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 - Issue #2054: ftplib now provides an FTP_TLS class to do secure FTP using
TLS or SSL. Patch by Giampaolo Rodola'. TLS or SSL. Patch by Giampaolo Rodola'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment