[Python-checkins] r76314 - in python/branches/py3k: Lib/pydoc.py Misc/NEWS

nick.coghlan python-checkins at python.org
Mon Nov 16 00:04:34 CET 2009


Author: nick.coghlan
Date: Mon Nov 16 00:04:33 2009
New Revision: 76314

Log:
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
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/pydoc.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/pydoc.py
==============================================================================
--- python/branches/py3k/Lib/pydoc.py	(original)
+++ python/branches/py3k/Lib/pydoc.py	Mon Nov 16 00:04:33 2009
@@ -2249,11 +2249,13 @@
     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')

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Mon Nov 16 00:04:33 2009
@@ -132,6 +132,8 @@
 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.
 


More information about the Python-checkins mailing list