summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xLib/pydoc.py12
-rw-r--r--Misc/NEWS2
2 files changed, 9 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')
diff --git a/Misc/NEWS b/Misc/NEWS
index 438352e..1c92be0 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -132,6 +132,8 @@ C-API
Library
-------
+- Issue #7328: pydoc no longer corrupts sys.path when run with the '-m' switch
+
- Issue #4969: The mimetypes module now reads the MIME database from
the registry under Windows. Patch by Gabriel Genellina.