diff -r 9066dca1a9b3 Doc/library/functions.rst --- a/Doc/library/functions.rst Sun Aug 05 19:24:57 2012 -0400 +++ b/Doc/library/functions.rst Sun Aug 05 19:47:26 2012 -0400 @@ -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 -r 9066dca1a9b3 Doc/library/importlib.rst --- a/Doc/library/importlib.rst Sun Aug 05 19:24:57 2012 -0400 +++ b/Doc/library/importlib.rst Sun Aug 05 19:47:26 2012 -0400 @@ -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 -r 9066dca1a9b3 Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Sun Aug 05 19:24:57 2012 -0400 +++ b/Lib/importlib/_bootstrap.py Sun Aug 05 19:47:26 2012 -0400 @@ -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 -r 9066dca1a9b3 Misc/NEWS --- a/Misc/NEWS Sun Aug 05 19:24:57 2012 -0400 +++ b/Misc/NEWS Sun Aug 05 19:47:26 2012 -0400 @@ -77,6 +77,9 @@ Library ------- +- 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 -r 9066dca1a9b3 Python/bltinmodule.c --- a/Python/bltinmodule.c Sun Aug 05 19:24:57 2012 -0400 +++ b/Python/bltinmodule.c Sun Aug 05 19:47:26 2012 -0400 @@ -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 -r 9066dca1a9b3 Python/importlib.h --- a/Python/importlib.h Sun Aug 05 19:24:57 2012 -0400 +++ b/Python/importlib.h Sun Aug 05 19:47:26 2012 -0400 @@ -57,8 +57,8 @@ 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, 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, - 0,0,105,0,0,103,0,0,100,45,0,100,119,0,100,120, + 90,68,0,100,117,0,100,118,0,132,0,0,90,69,0,100, + 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, 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, @@ -3912,69 +3912,72 @@ 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, 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, - 203,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, - 1,0,124,1,0,131,1,0,125,6,0,116,0,0,124,0, - 0,124,6,0,124,4,0,131,3,0,125,5,0,124,3,0, - 115,183,0,124,4,0,100,1,0,107,2,0,114,98,0,116, - 0,0,124,0,0,106,2,0,100,2,0,131,1,0,100,1, - 0,25,131,1,0,83,124,0,0,115,108,0,124,5,0,83, - 116,3,0,124,0,0,131,1,0,116,3,0,124,0,0,106, - 2,0,100,2,0,131,1,0,100,1,0,25,131,1,0,24, - 125,7,0,116,4,0,106,5,0,124,5,0,106,6,0,100, - 3,0,116,3,0,124,5,0,106,6,0,131,1,0,124,7, - 0,24,133,2,0,25,25,83,110,16,0,116,7,0,124,5, - 0,124,3,0,116,0,0,131,3,0,83,100,3,0,83,40, - 4,0,0,0,117,214,1,0,0,73,109,112,111,114,116,32, - 97,32,109,111,100,117,108,101,46,10,10,32,32,32,32,84, - 104,101,32,39,103,108,111,98,97,108,115,39,32,97,114,103, - 117,109,101,110,116,32,105,115,32,117,115,101,100,32,116,111, - 32,105,110,102,101,114,32,119,104,101,114,101,32,116,104,101, - 32,105,109,112,111,114,116,32,105,115,32,111,99,99,117,114, - 105,110,103,32,102,114,111,109,10,32,32,32,32,116,111,32, - 104,97,110,100,108,101,32,114,101,108,97,116,105,118,101,32, - 105,109,112,111,114,116,115,46,32,84,104,101,32,39,108,111, - 99,97,108,115,39,32,97,114,103,117,109,101,110,116,32,105, - 115,32,105,103,110,111,114,101,100,46,32,84,104,101,10,32, - 32,32,32,39,102,114,111,109,108,105,115,116,39,32,97,114, - 103,117,109,101,110,116,32,115,112,101,99,105,102,105,101,115, - 32,119,104,97,116,32,115,104,111,117,108,100,32,101,120,105, - 115,116,32,97,115,32,97,116,116,114,105,98,117,116,101,115, - 32,111,110,32,116,104,101,32,109,111,100,117,108,101,10,32, - 32,32,32,98,101,105,110,103,32,105,109,112,111,114,116,101, - 100,32,40,101,46,103,46,32,96,96,102,114,111,109,32,109, - 111,100,117,108,101,32,105,109,112,111,114,116,32,60,102,114, - 111,109,108,105,115,116,62,96,96,41,46,32,32,84,104,101, - 32,39,108,101,118,101,108,39,10,32,32,32,32,97,114,103, - 117,109,101,110,116,32,114,101,112,114,101,115,101,110,116,115, - 32,116,104,101,32,112,97,99,107,97,103,101,32,108,111,99, - 97,116,105,111,110,32,116,111,32,105,109,112,111,114,116,32, - 102,114,111,109,32,105,110,32,97,32,114,101,108,97,116,105, - 118,101,10,32,32,32,32,105,109,112,111,114,116,32,40,101, - 46,103,46,32,96,96,102,114,111,109,32,46,46,112,107,103, - 32,105,109,112,111,114,116,32,109,111,100,96,96,32,119,111, - 117,108,100,32,104,97,118,101,32,97,32,39,108,101,118,101, - 108,39,32,111,102,32,50,41,46,10,10,32,32,32,32,105, - 0,0,0,0,117,1,0,0,0,46,78,40,8,0,0,0, - 117,11,0,0,0,95,103,99,100,95,105,109,112,111,114,116, - 117,17,0,0,0,95,99,97,108,99,95,95,95,112,97,99, - 107,97,103,101,95,95,117,9,0,0,0,112,97,114,116,105, - 116,105,111,110,117,3,0,0,0,108,101,110,117,3,0,0, - 0,115,121,115,117,7,0,0,0,109,111,100,117,108,101,115, - 117,8,0,0,0,95,95,110,97,109,101,95,95,117,16,0, - 0,0,95,104,97,110,100,108,101,95,102,114,111,109,108,105, - 115,116,40,8,0,0,0,117,4,0,0,0,110,97,109,101, - 117,7,0,0,0,103,108,111,98,97,108,115,117,6,0,0, - 0,108,111,99,97,108,115,117,8,0,0,0,102,114,111,109, - 108,105,115,116,117,5,0,0,0,108,101,118,101,108,117,6, - 0,0,0,109,111,100,117,108,101,117,7,0,0,0,112,97, - 99,107,97,103,101,117,7,0,0,0,99,117,116,95,111,102, - 102,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,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,24,0,0,0,0,11,12,1,15,2,12,1,18,1,6, + 0,0,0,9,0,0,0,5,0,0,0,67,0,0,0,115, + 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,54,0,124, + 1,0,100,3,0,107,9,0,114,45,0,124,1,0,110,3, + 0,105,0,0,125,6,0,116,2,0,124,6,0,131,1,0, + 125,7,0,116,0,0,124,0,0,124,7,0,124,4,0,131, + 3,0,125,5,0,124,3,0,115,207,0,124,4,0,100,1, + 0,107,2,0,114,122,0,116,0,0,124,0,0,106,3,0, + 100,2,0,131,1,0,100,1,0,25,131,1,0,83,124,0, + 0,115,132,0,124,5,0,83,116,4,0,124,0,0,131,1, + 0,116,4,0,124,0,0,106,3,0,100,2,0,131,1,0, + 100,1,0,25,131,1,0,24,125,8,0,116,5,0,106,6, + 0,124,5,0,106,7,0,100,3,0,116,4,0,124,5,0, + 106,7,0,131,1,0,124,8,0,24,133,2,0,25,25,83, + 110,16,0,116,8,0,124,5,0,124,3,0,116,0,0,131, + 3,0,83,100,3,0,83,40,4,0,0,0,117,214,1,0, + 0,73,109,112,111,114,116,32,97,32,109,111,100,117,108,101, + 46,10,10,32,32,32,32,84,104,101,32,39,103,108,111,98, + 97,108,115,39,32,97,114,103,117,109,101,110,116,32,105,115, + 32,117,115,101,100,32,116,111,32,105,110,102,101,114,32,119, + 104,101,114,101,32,116,104,101,32,105,109,112,111,114,116,32, + 105,115,32,111,99,99,117,114,105,110,103,32,102,114,111,109, + 10,32,32,32,32,116,111,32,104,97,110,100,108,101,32,114, + 101,108,97,116,105,118,101,32,105,109,112,111,114,116,115,46, + 32,84,104,101,32,39,108,111,99,97,108,115,39,32,97,114, + 103,117,109,101,110,116,32,105,115,32,105,103,110,111,114,101, + 100,46,32,84,104,101,10,32,32,32,32,39,102,114,111,109, + 108,105,115,116,39,32,97,114,103,117,109,101,110,116,32,115, + 112,101,99,105,102,105,101,115,32,119,104,97,116,32,115,104, + 111,117,108,100,32,101,120,105,115,116,32,97,115,32,97,116, + 116,114,105,98,117,116,101,115,32,111,110,32,116,104,101,32, + 109,111,100,117,108,101,10,32,32,32,32,98,101,105,110,103, + 32,105,109,112,111,114,116,101,100,32,40,101,46,103,46,32, + 96,96,102,114,111,109,32,109,111,100,117,108,101,32,105,109, + 112,111,114,116,32,60,102,114,111,109,108,105,115,116,62,96, + 96,41,46,32,32,84,104,101,32,39,108,101,118,101,108,39, + 10,32,32,32,32,97,114,103,117,109,101,110,116,32,114,101, + 112,114,101,115,101,110,116,115,32,116,104,101,32,112,97,99, + 107,97,103,101,32,108,111,99,97,116,105,111,110,32,116,111, + 32,105,109,112,111,114,116,32,102,114,111,109,32,105,110,32, + 97,32,114,101,108,97,116,105,118,101,10,32,32,32,32,105, + 109,112,111,114,116,32,40,101,46,103,46,32,96,96,102,114, + 111,109,32,46,46,112,107,103,32,105,109,112,111,114,116,32, + 109,111,100,96,96,32,119,111,117,108,100,32,104,97,118,101, + 32,97,32,39,108,101,118,101,108,39,32,111,102,32,50,41, + 46,10,10,32,32,32,32,105,0,0,0,0,117,1,0,0, + 0,46,78,40,9,0,0,0,117,11,0,0,0,95,103,99, + 100,95,105,109,112,111,114,116,117,4,0,0,0,78,111,110, + 101,117,17,0,0,0,95,99,97,108,99,95,95,95,112,97, + 99,107,97,103,101,95,95,117,9,0,0,0,112,97,114,116, + 105,116,105,111,110,117,3,0,0,0,108,101,110,117,3,0, + 0,0,115,121,115,117,7,0,0,0,109,111,100,117,108,101, + 115,117,8,0,0,0,95,95,110,97,109,101,95,95,117,16, + 0,0,0,95,104,97,110,100,108,101,95,102,114,111,109,108, + 105,115,116,40,9,0,0,0,117,4,0,0,0,110,97,109, + 101,117,7,0,0,0,103,108,111,98,97,108,115,117,6,0, + 0,0,108,111,99,97,108,115,117,8,0,0,0,102,114,111, + 109,108,105,115,116,117,5,0,0,0,108,101,118,101,108,117, + 6,0,0,0,109,111,100,117,108,101,117,8,0,0,0,103, + 108,111,98,97,108,115,95,117,7,0,0,0,112,97,99,107, + 97,103,101,117,7,0,0,0,99,117,116,95,111,102,102,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,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, 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, @@ -4052,7 +4055,7 @@ 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, 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, 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, @@ -4107,7 +4110,7 @@ 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, 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, 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, @@ -4150,7 +4153,7 @@ 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, 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, 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, @@ -4252,5 +4255,5 @@ 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,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, };