[Python-checkins] cpython (merge default -> default): merge heads

benjamin.peterson python-checkins at python.org
Tue Aug 7 02:53:28 CEST 2012


http://hg.python.org/cpython/rev/0eeffeadaa1e
changeset:   78459:0eeffeadaa1e
parent:      78458:ee55f8e4fb50
parent:      78457:6a27b9f37b05
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon Aug 06 17:53:19 2012 -0700
summary:
  merge heads

files:
  Doc/library/functions.rst   |    2 +-
  Doc/library/importlib.rst   |    2 +-
  Doc/library/stdtypes.rst    |   13 +-
  Lib/importlib/_bootstrap.py |    5 +-
  Lib/pydoc.py                |   10 +-
  Misc/NEWS                   |    5 +
  Python/bltinmodule.c        |    2 +-
  Python/importlib.h          |  141 ++++++++++++-----------
  8 files changed, 96 insertions(+), 84 deletions(-)


diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1443,7 +1443,7 @@
       True
 
 
-.. function:: __import__(name, globals={}, locals={}, fromlist=[], level=0)
+.. function:: __import__(name, globals=None, locals=None, fromlist=(), level=0)
 
    .. index::
       statement: import
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -63,7 +63,7 @@
 Functions
 ---------
 
-.. function:: __import__(name, globals={}, locals={}, fromlist=list(), level=0)
+.. function:: __import__(name, globals=None, locals=None, fromlist=(), level=0)
 
     An implementation of the built-in :func:`__import__` function.
 
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1351,16 +1351,19 @@
 
 .. method:: str.splitlines([keepends])
 
-   Return a list of the lines in the string, breaking at line boundaries.  Line
-   breaks are not included in the resulting list unless *keepends* is given and
-   true. This method uses the universal newlines approach to splitting lines.
-   Unlike :meth:`~str.split`, if the string ends with line boundary characters
-   the returned list does ``not`` have an empty last element.
+   Return a list of the lines in the string, breaking at line boundaries.
+   This method uses the universal newlines approach to splitting lines.
+   Line breaks are not included in the resulting list unless *keepends* is
+   given and true.
 
    For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
    ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)``
    returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``.
 
+   Unlike :meth:`~str.split` when a delimiter string *sep* is given, this
+   method returns an empty list for the empty string, and a terminal line
+   break does not result in an extra line.
+
 
 .. method:: str.startswith(prefix[, start[, end]])
 
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1587,7 +1587,7 @@
     return [extensions, source, bytecode]
 
 
-def __import__(name, globals={}, locals={}, fromlist=[], level=0):
+def __import__(name, globals=None, locals=None, fromlist=(), level=0):
     """Import a module.
 
     The 'globals' argument is used to infer where the import is occuring from
@@ -1601,7 +1601,8 @@
     if level == 0:
         module = _gcd_import(name)
     else:
-        package = _calc___package__(globals)
+        globals_ = globals if globals is not None else {}
+        package = _calc___package__(globals_)
         module = _gcd_import(name, package, level)
     if not fromlist:
         # Return up to the first dot in 'name'. This is complicated by the fact
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -163,11 +163,11 @@
 
 def visiblename(name, all=None, obj=None):
     """Decide whether to show documentation on a variable."""
-    # Certain special names are redundant.
-    if name in {'__builtins__', '__doc__', '__file__', '__path__',
-                     '__module__', '__name__', '__slots__', '__package__',
-                     '__cached__', '__author__', '__credits__', '__date__',
-                     '__version__', '__qualname__', '__initializing__'}:
+    # Certain special names are redundant or internal.
+    if name in {'__author__', '__builtins__', '__cached__', '__credits__',
+                '__date__', '__doc__', '__file__', '__initializing__',
+                '__loader__', '__module__', '__name__', '__package__',
+                '__path__', '__qualname__', '__slots__', '__version__'}:
         return 0
     # Private names are hidden, but special names are displayed.
     if name.startswith('__') and name.endswith('__'): return 1
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -80,6 +80,11 @@
 Library
 -------
 
+- Issue #15163: Pydoc shouldn't list __loader__ as module data.
+
+- Issue #15471: Do not use mutable objects as defaults for
+  importlib.__import__().
+
 - Issue #15559: To avoid a problematic failure mode when passed to the bytes
   constructor, objects in the ipaddress module no longer implement __index__
   (they still implement __int__ as appropriate)
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -195,7 +195,7 @@
 }
 
 PyDoc_STRVAR(import_doc,
-"__import__(name, globals={}, locals={}, fromlist=[], level=0) -> module\n\
+"__import__(name, globals=None, locals=None, fromlist=(), level=0) -> module\n\
 \n\
 Import a module. Because this function is meant for use by the Python\n\
 interpreter and not for general use it is better to use\n\
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list