]> granicus.if.org Git - python/commitdiff
Merged revisions 76312 via svnmerge from
authorNick Coghlan <ncoghlan@gmail.com>
Sun, 15 Nov 2009 23:04:33 +0000 (23:04 +0000)
committerNick Coghlan <ncoghlan@gmail.com>
Sun, 15 Nov 2009 23:04:33 +0000 (23:04 +0000)
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
........

Lib/pydoc.py
Misc/NEWS

index 68771c9f08b95bbb2c7e545eb178155aa406a1a7..28d3bb8c5fbc7fcfc18d48c1f4607307708ff12c 100755 (executable)
@@ -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')
index 438352ee5111c0b8c027b8924f5e198d7b3aa79f..1c92be0fd1602dc5bb8d669b4c79d534451d27c4 100644 (file)
--- 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.