merge heads

This commit is contained in:
Benjamin Peterson 2012-08-06 17:53:19 -07:00
commit 0ed05059de
8 changed files with 96 additions and 84 deletions

View File

@ -1443,7 +1443,7 @@ are always available. They are listed here in alphabetical order.
True True
.. function:: __import__(name, globals={}, locals={}, fromlist=[], level=0) .. function:: __import__(name, globals=None, locals=None, fromlist=(), level=0)
.. index:: .. index::
statement: import statement: import

View File

@ -63,7 +63,7 @@ Details on custom importers can be found in :pep:`302`.
Functions 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. An implementation of the built-in :func:`__import__` function.

View File

@ -1351,16 +1351,19 @@ functions based on regular expressions.
.. method:: str.splitlines([keepends]) .. method:: str.splitlines([keepends])
Return a list of the lines in the string, breaking at line boundaries. Line Return a list of the lines in the string, breaking at line boundaries.
breaks are not included in the resulting list unless *keepends* is given and This method uses the universal newlines approach to splitting lines.
true. This method uses the universal newlines approach to splitting lines. Line breaks are not included in the resulting list unless *keepends* is
Unlike :meth:`~str.split`, if the string ends with line boundary characters given and true.
the returned list does ``not`` have an empty last element.
For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)`` ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)``
returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``. 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]]) .. method:: str.startswith(prefix[, start[, end]])

View File

@ -1587,7 +1587,7 @@ def _get_supported_file_loaders():
return [extensions, source, bytecode] 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. """Import a module.
The 'globals' argument is used to infer where the import is occuring from The 'globals' argument is used to infer where the import is occuring from
@ -1601,7 +1601,8 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
if level == 0: if level == 0:
module = _gcd_import(name) module = _gcd_import(name)
else: else:
package = _calc___package__(globals) globals_ = globals if globals is not None else {}
package = _calc___package__(globals_)
module = _gcd_import(name, package, level) module = _gcd_import(name, package, level)
if not fromlist: if not fromlist:
# Return up to the first dot in 'name'. This is complicated by the fact # Return up to the first dot in 'name'. This is complicated by the fact

View File

@ -163,11 +163,11 @@ def _split_list(s, predicate):
def visiblename(name, all=None, obj=None): def visiblename(name, all=None, obj=None):
"""Decide whether to show documentation on a variable.""" """Decide whether to show documentation on a variable."""
# Certain special names are redundant. # Certain special names are redundant or internal.
if name in {'__builtins__', '__doc__', '__file__', '__path__', if name in {'__author__', '__builtins__', '__cached__', '__credits__',
'__module__', '__name__', '__slots__', '__package__', '__date__', '__doc__', '__file__', '__initializing__',
'__cached__', '__author__', '__credits__', '__date__', '__loader__', '__module__', '__name__', '__package__',
'__version__', '__qualname__', '__initializing__'}: '__path__', '__qualname__', '__slots__', '__version__'}:
return 0 return 0
# Private names are hidden, but special names are displayed. # Private names are hidden, but special names are displayed.
if name.startswith('__') and name.endswith('__'): return 1 if name.startswith('__') and name.endswith('__'): return 1

View File

@ -80,6 +80,11 @@ Core and Builtins
Library 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 - Issue #15559: To avoid a problematic failure mode when passed to the bytes
constructor, objects in the ipaddress module no longer implement __index__ constructor, objects in the ipaddress module no longer implement __index__
(they still implement __int__ as appropriate) (they still implement __int__ as appropriate)

View File

@ -195,7 +195,7 @@ builtin___import__(PyObject *self, PyObject *args, PyObject *kwds)
} }
PyDoc_STRVAR(import_doc, 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\ \n\
Import a module. Because this function is meant for use by the Python\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\ interpreter and not for general use it is better to use\n\

View File

@ -57,8 +57,8 @@ unsigned char _Py_M__importlib[] = {
100,110,0,132,0,0,90,65,0,100,125,0,100,45,0,100, 100,110,0,132,0,0,90,65,0,100,125,0,100,45,0,100,
111,0,100,112,0,132,2,0,90,66,0,100,113,0,100,114, 111,0,100,112,0,132,2,0,90,66,0,100,113,0,100,114,
0,132,0,0,90,67,0,100,115,0,100,116,0,132,0,0, 0,132,0,0,90,67,0,100,115,0,100,116,0,132,0,0,
90,68,0,100,117,0,100,118,0,132,0,0,90,69,0,105, 90,68,0,100,117,0,100,118,0,132,0,0,90,69,0,100,
0,0,105,0,0,103,0,0,100,45,0,100,119,0,100,120, 125,0,100,125,0,102,0,0,100,45,0,100,119,0,100,120,
0,132,4,0,90,70,0,100,121,0,100,122,0,132,0,0, 0,132,4,0,90,70,0,100,121,0,100,122,0,132,0,0,
90,71,0,100,123,0,100,124,0,132,0,0,90,72,0,100, 90,71,0,100,123,0,100,124,0,132,0,0,90,72,0,100,
125,0,83,40,127,0,0,0,117,83,1,0,0,67,111,114, 125,0,83,40,127,0,0,0,117,83,1,0,0,67,111,114,
@ -3912,69 +3912,72 @@ unsigned char _Py_M__importlib[] = {
0,0,0,5,21,1,15,1,15,1,117,27,0,0,0,95, 0,0,0,5,21,1,15,1,15,1,117,27,0,0,0,95,
103,101,116,95,115,117,112,112,111,114,116,101,100,95,102,105, 103,101,116,95,115,117,112,112,111,114,116,101,100,95,102,105,
108,101,95,108,111,97,100,101,114,115,99,5,0,0,0,0, 108,101,95,108,111,97,100,101,114,115,99,5,0,0,0,0,
0,0,0,8,0,0,0,5,0,0,0,67,0,0,0,115, 0,0,0,9,0,0,0,5,0,0,0,67,0,0,0,115,
203,0,0,0,124,4,0,100,1,0,107,2,0,114,27,0, 227,0,0,0,124,4,0,100,1,0,107,2,0,114,27,0,
116,0,0,124,0,0,131,1,0,125,5,0,110,30,0,116, 116,0,0,124,0,0,131,1,0,125,5,0,110,54,0,124,
1,0,124,1,0,131,1,0,125,6,0,116,0,0,124,0, 1,0,100,3,0,107,9,0,114,45,0,124,1,0,110,3,
0,124,6,0,124,4,0,131,3,0,125,5,0,124,3,0, 0,105,0,0,125,6,0,116,2,0,124,6,0,131,1,0,
115,183,0,124,4,0,100,1,0,107,2,0,114,98,0,116, 125,7,0,116,0,0,124,0,0,124,7,0,124,4,0,131,
0,0,124,0,0,106,2,0,100,2,0,131,1,0,100,1, 3,0,125,5,0,124,3,0,115,207,0,124,4,0,100,1,
0,25,131,1,0,83,124,0,0,115,108,0,124,5,0,83, 0,107,2,0,114,122,0,116,0,0,124,0,0,106,3,0,
116,3,0,124,0,0,131,1,0,116,3,0,124,0,0,106, 100,2,0,131,1,0,100,1,0,25,131,1,0,83,124,0,
2,0,100,2,0,131,1,0,100,1,0,25,131,1,0,24, 0,115,132,0,124,5,0,83,116,4,0,124,0,0,131,1,
125,7,0,116,4,0,106,5,0,124,5,0,106,6,0,100, 0,116,4,0,124,0,0,106,3,0,100,2,0,131,1,0,
3,0,116,3,0,124,5,0,106,6,0,131,1,0,124,7, 100,1,0,25,131,1,0,24,125,8,0,116,5,0,106,6,
0,24,133,2,0,25,25,83,110,16,0,116,7,0,124,5, 0,124,5,0,106,7,0,100,3,0,116,4,0,124,5,0,
0,124,3,0,116,0,0,131,3,0,83,100,3,0,83,40, 106,7,0,131,1,0,124,8,0,24,133,2,0,25,25,83,
4,0,0,0,117,214,1,0,0,73,109,112,111,114,116,32, 110,16,0,116,8,0,124,5,0,124,3,0,116,0,0,131,
97,32,109,111,100,117,108,101,46,10,10,32,32,32,32,84, 3,0,83,100,3,0,83,40,4,0,0,0,117,214,1,0,
104,101,32,39,103,108,111,98,97,108,115,39,32,97,114,103, 0,73,109,112,111,114,116,32,97,32,109,111,100,117,108,101,
117,109,101,110,116,32,105,115,32,117,115,101,100,32,116,111, 46,10,10,32,32,32,32,84,104,101,32,39,103,108,111,98,
32,105,110,102,101,114,32,119,104,101,114,101,32,116,104,101, 97,108,115,39,32,97,114,103,117,109,101,110,116,32,105,115,
32,105,109,112,111,114,116,32,105,115,32,111,99,99,117,114, 32,117,115,101,100,32,116,111,32,105,110,102,101,114,32,119,
105,110,103,32,102,114,111,109,10,32,32,32,32,116,111,32, 104,101,114,101,32,116,104,101,32,105,109,112,111,114,116,32,
104,97,110,100,108,101,32,114,101,108,97,116,105,118,101,32, 105,115,32,111,99,99,117,114,105,110,103,32,102,114,111,109,
105,109,112,111,114,116,115,46,32,84,104,101,32,39,108,111, 10,32,32,32,32,116,111,32,104,97,110,100,108,101,32,114,
99,97,108,115,39,32,97,114,103,117,109,101,110,116,32,105, 101,108,97,116,105,118,101,32,105,109,112,111,114,116,115,46,
115,32,105,103,110,111,114,101,100,46,32,84,104,101,10,32, 32,84,104,101,32,39,108,111,99,97,108,115,39,32,97,114,
32,32,32,39,102,114,111,109,108,105,115,116,39,32,97,114, 103,117,109,101,110,116,32,105,115,32,105,103,110,111,114,101,
103,117,109,101,110,116,32,115,112,101,99,105,102,105,101,115, 100,46,32,84,104,101,10,32,32,32,32,39,102,114,111,109,
32,119,104,97,116,32,115,104,111,117,108,100,32,101,120,105, 108,105,115,116,39,32,97,114,103,117,109,101,110,116,32,115,
115,116,32,97,115,32,97,116,116,114,105,98,117,116,101,115, 112,101,99,105,102,105,101,115,32,119,104,97,116,32,115,104,
32,111,110,32,116,104,101,32,109,111,100,117,108,101,10,32, 111,117,108,100,32,101,120,105,115,116,32,97,115,32,97,116,
32,32,32,98,101,105,110,103,32,105,109,112,111,114,116,101, 116,114,105,98,117,116,101,115,32,111,110,32,116,104,101,32,
100,32,40,101,46,103,46,32,96,96,102,114,111,109,32,109, 109,111,100,117,108,101,10,32,32,32,32,98,101,105,110,103,
111,100,117,108,101,32,105,109,112,111,114,116,32,60,102,114, 32,105,109,112,111,114,116,101,100,32,40,101,46,103,46,32,
111,109,108,105,115,116,62,96,96,41,46,32,32,84,104,101, 96,96,102,114,111,109,32,109,111,100,117,108,101,32,105,109,
32,39,108,101,118,101,108,39,10,32,32,32,32,97,114,103, 112,111,114,116,32,60,102,114,111,109,108,105,115,116,62,96,
117,109,101,110,116,32,114,101,112,114,101,115,101,110,116,115, 96,41,46,32,32,84,104,101,32,39,108,101,118,101,108,39,
32,116,104,101,32,112,97,99,107,97,103,101,32,108,111,99, 10,32,32,32,32,97,114,103,117,109,101,110,116,32,114,101,
97,116,105,111,110,32,116,111,32,105,109,112,111,114,116,32, 112,114,101,115,101,110,116,115,32,116,104,101,32,112,97,99,
102,114,111,109,32,105,110,32,97,32,114,101,108,97,116,105, 107,97,103,101,32,108,111,99,97,116,105,111,110,32,116,111,
118,101,10,32,32,32,32,105,109,112,111,114,116,32,40,101, 32,105,109,112,111,114,116,32,102,114,111,109,32,105,110,32,
46,103,46,32,96,96,102,114,111,109,32,46,46,112,107,103, 97,32,114,101,108,97,116,105,118,101,10,32,32,32,32,105,
32,105,109,112,111,114,116,32,109,111,100,96,96,32,119,111, 109,112,111,114,116,32,40,101,46,103,46,32,96,96,102,114,
117,108,100,32,104,97,118,101,32,97,32,39,108,101,118,101, 111,109,32,46,46,112,107,103,32,105,109,112,111,114,116,32,
108,39,32,111,102,32,50,41,46,10,10,32,32,32,32,105, 109,111,100,96,96,32,119,111,117,108,100,32,104,97,118,101,
0,0,0,0,117,1,0,0,0,46,78,40,8,0,0,0, 32,97,32,39,108,101,118,101,108,39,32,111,102,32,50,41,
117,11,0,0,0,95,103,99,100,95,105,109,112,111,114,116, 46,10,10,32,32,32,32,105,0,0,0,0,117,1,0,0,
117,17,0,0,0,95,99,97,108,99,95,95,95,112,97,99, 0,46,78,40,9,0,0,0,117,11,0,0,0,95,103,99,
107,97,103,101,95,95,117,9,0,0,0,112,97,114,116,105, 100,95,105,109,112,111,114,116,117,4,0,0,0,78,111,110,
116,105,111,110,117,3,0,0,0,108,101,110,117,3,0,0, 101,117,17,0,0,0,95,99,97,108,99,95,95,95,112,97,
0,115,121,115,117,7,0,0,0,109,111,100,117,108,101,115, 99,107,97,103,101,95,95,117,9,0,0,0,112,97,114,116,
117,8,0,0,0,95,95,110,97,109,101,95,95,117,16,0, 105,116,105,111,110,117,3,0,0,0,108,101,110,117,3,0,
0,0,95,104,97,110,100,108,101,95,102,114,111,109,108,105, 0,0,115,121,115,117,7,0,0,0,109,111,100,117,108,101,
115,116,40,8,0,0,0,117,4,0,0,0,110,97,109,101, 115,117,8,0,0,0,95,95,110,97,109,101,95,95,117,16,
117,7,0,0,0,103,108,111,98,97,108,115,117,6,0,0, 0,0,0,95,104,97,110,100,108,101,95,102,114,111,109,108,
0,108,111,99,97,108,115,117,8,0,0,0,102,114,111,109, 105,115,116,40,9,0,0,0,117,4,0,0,0,110,97,109,
108,105,115,116,117,5,0,0,0,108,101,118,101,108,117,6, 101,117,7,0,0,0,103,108,111,98,97,108,115,117,6,0,
0,0,0,109,111,100,117,108,101,117,7,0,0,0,112,97, 0,0,108,111,99,97,108,115,117,8,0,0,0,102,114,111,
99,107,97,103,101,117,7,0,0,0,99,117,116,95,111,102, 109,108,105,115,116,117,5,0,0,0,108,101,118,101,108,117,
102,40,0,0,0,0,40,0,0,0,0,117,29,0,0,0, 6,0,0,0,109,111,100,117,108,101,117,8,0,0,0,103,
60,102,114,111,122,101,110,32,105,109,112,111,114,116,108,105, 108,111,98,97,108,115,95,117,7,0,0,0,112,97,99,107,
98,46,95,98,111,111,116,115,116,114,97,112,62,117,10,0, 97,103,101,117,7,0,0,0,99,117,116,95,111,102,102,40,
0,0,95,95,105,109,112,111,114,116,95,95,54,6,0,0, 0,0,0,0,40,0,0,0,0,117,29,0,0,0,60,102,
115,24,0,0,0,0,11,12,1,15,2,12,1,18,1,6, 114,111,122,101,110,32,105,109,112,111,114,116,108,105,98,46,
95,98,111,111,116,115,116,114,97,112,62,117,10,0,0,0,
95,95,105,109,112,111,114,116,95,95,54,6,0,0,115,26,
0,0,0,0,11,12,1,15,2,24,1,12,1,18,1,6,
3,12,1,23,1,6,1,4,2,35,1,40,2,117,10,0, 3,12,1,23,1,6,1,4,2,35,1,40,2,117,10,0,
0,0,95,95,105,109,112,111,114,116,95,95,99,2,0,0, 0,0,95,95,105,109,112,111,114,116,95,95,99,2,0,0,
0,0,0,0,0,14,0,0,0,13,0,0,0,67,0,0, 0,0,0,0,0,14,0,0,0,13,0,0,0,67,0,0,
@ -4052,7 +4055,7 @@ unsigned char _Py_M__importlib[] = {
40,0,0,0,0,40,0,0,0,0,117,29,0,0,0,60, 40,0,0,0,0,40,0,0,0,0,117,29,0,0,0,60,
102,114,111,122,101,110,32,105,109,112,111,114,116,108,105,98, 102,114,111,122,101,110,32,105,109,112,111,114,116,108,105,98,
46,95,98,111,111,116,115,116,114,97,112,62,117,9,0,0, 46,95,98,111,111,116,115,116,114,97,112,62,117,9,0,0,
0,60,103,101,110,101,120,112,114,62,112,6,0,0,115,2, 0,60,103,101,110,101,120,112,114,62,113,6,0,0,115,2,
0,0,0,6,0,117,25,0,0,0,95,115,101,116,117,112, 0,0,0,6,0,117,25,0,0,0,95,115,101,116,117,112,
46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,120, 46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,120,
112,114,62,105,0,0,0,0,117,7,0,0,0,69,77,88, 112,114,62,105,0,0,0,0,117,7,0,0,0,69,77,88,
@ -4107,7 +4110,7 @@ unsigned char _Py_M__importlib[] = {
109,111,100,117,108,101,40,0,0,0,0,40,0,0,0,0, 109,111,100,117,108,101,40,0,0,0,0,40,0,0,0,0,
117,29,0,0,0,60,102,114,111,122,101,110,32,105,109,112, 117,29,0,0,0,60,102,114,111,122,101,110,32,105,109,112,
111,114,116,108,105,98,46,95,98,111,111,116,115,116,114,97, 111,114,116,108,105,98,46,95,98,111,111,116,115,116,114,97,
112,62,117,6,0,0,0,95,115,101,116,117,112,85,6,0, 112,62,117,6,0,0,0,95,115,101,116,117,112,86,6,0,
0,115,88,0,0,0,0,9,6,1,6,2,19,1,15,1, 0,115,88,0,0,0,0,9,6,1,6,2,19,1,15,1,
16,2,13,1,13,1,15,1,18,2,13,1,20,2,48,1, 16,2,13,1,13,1,15,1,18,2,13,1,20,2,48,1,
19,2,31,1,10,1,15,1,13,1,4,2,3,1,15,2, 19,2,31,1,10,1,15,1,13,1,4,2,3,1,15,2,
@ -4150,7 +4153,7 @@ unsigned char _Py_M__importlib[] = {
111,97,100,101,114,115,40,0,0,0,0,40,0,0,0,0, 111,97,100,101,114,115,40,0,0,0,0,40,0,0,0,0,
117,29,0,0,0,60,102,114,111,122,101,110,32,105,109,112, 117,29,0,0,0,60,102,114,111,122,101,110,32,105,109,112,
111,114,116,108,105,98,46,95,98,111,111,116,115,116,114,97, 111,114,116,108,105,98,46,95,98,111,111,116,115,116,114,97,
112,62,117,8,0,0,0,95,105,110,115,116,97,108,108,153, 112,62,117,8,0,0,0,95,105,110,115,116,97,108,108,154,
6,0,0,115,16,0,0,0,0,2,13,1,9,1,28,1, 6,0,0,115,16,0,0,0,0,2,13,1,9,1,28,1,
16,1,16,1,15,1,19,1,117,8,0,0,0,95,105,110, 16,1,16,1,15,1,19,1,117,8,0,0,0,95,105,110,
115,116,97,108,108,78,40,3,0,0,0,117,3,0,0,0, 115,116,97,108,108,78,40,3,0,0,0,117,3,0,0,0,
@ -4252,5 +4255,5 @@ unsigned char _Py_M__importlib[] = {
12,18,12,11,12,13,19,57,19,54,19,50,19,82,22,124, 12,18,12,11,12,13,19,57,19,54,19,50,19,82,22,124,
19,29,25,38,25,24,19,41,19,55,19,18,19,81,19,135, 19,29,25,38,25,24,19,41,19,55,19,18,19,81,19,135,
19,13,12,9,12,17,12,17,6,2,12,46,12,13,18,24, 19,13,12,9,12,17,12,17,6,2,12,46,12,13,18,24,
12,23,12,15,12,11,24,31,12,68, 12,23,12,15,12,11,24,32,12,68,
}; };