<div dir="ltr">FYI, Raymond let me know that this is causing the buildbots to occasionally fail thanks to<font face="Courier New, courier, monotype"><span style="font-size:12px"> </span></font>xml.parsers.expat.errors somehow circumventing import. I'm going to try and figure out what's going on.<div class="gmail_extra">
<br><div class="gmail_quote">On Fri, Feb 1, 2013 at 4:38 PM, brett.cannon <span dir="ltr"><<a href="mailto:python-checkins@python.org" target="_blank">python-checkins@python.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><a href="http://hg.python.org/cpython/rev/19ea454ccdf7" target="_blank">http://hg.python.org/cpython/rev/19ea454ccdf7</a><br>
changeset: 81884:19ea454ccdf7<br>
branch: 3.3<br>
parent: 81882:4a4688b865ff<br>
user: Brett Cannon <<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>><br>
date: Fri Feb 01 15:31:49 2013 -0500<br>
summary:<br>
Issue #17098: Be more stringent of setting __loader__ on early imported<br>
modules. Also made test more rigorous.<br>
<br>
files:<br>
Lib/importlib/_bootstrap.py | 7 +-<br>
Lib/test/test_importlib/test_api.py | 6 +<br>
Python/importlib.h | 591 ++++++++-------<br>
3 files changed, 310 insertions(+), 294 deletions(-)<br>
<br>
<br>
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py<br>
--- a/Lib/importlib/_bootstrap.py<br>
+++ b/Lib/importlib/_bootstrap.py<br>
@@ -1704,10 +1704,13 @@<br>
BYTECODE_SUFFIXES = DEBUG_BYTECODE_SUFFIXES<br>
<br>
module_type = type(sys)<br>
- for module in sys.modules.values():<br>
+ for name, module in sys.modules.items():<br>
if isinstance(module, module_type):<br>
if not hasattr(module, '__loader__'):<br>
- module.__loader__ = BuiltinImporter<br>
+ if name in sys.builtin_module_names:<br>
+ module.__loader__ = BuiltinImporter<br>
+ elif _imp.is_frozen(name):<br>
+ module.__loader__ = FrozenImporter<br>
<br>
self_module = sys.modules[__name__]<br>
for builtin_name in ('_io', '_warnings', 'builtins', 'marshal'):<br>
diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py<br>
--- a/Lib/test/test_importlib/test_api.py<br>
+++ b/Lib/test/test_importlib/test_api.py<br>
@@ -184,6 +184,12 @@<br>
if isinstance(module, types.ModuleType):<br>
self.assertTrue(hasattr(module, '__loader__'),<br>
'{!r} lacks a __loader__ attribute'.format(name))<br>
+ if name in sys.builtin_module_names:<br>
+ self.assertEqual(importlib.machinery.BuiltinImporter,<br>
+ module.__loader__)<br>
+ elif imp.is_frozen(name):<br>
+ self.assertEqual(importlib.machinery.FrozenImporter,<br>
+ module.__loader__)<br>
<br>
def test_main():<br>
from test.support import run_unittest<br>
diff --git a/Python/importlib.h b/Python/importlib.h<br>
--- a/Python/importlib.h<br>
+++ b/Python/importlib.h<br>
[stripped]<br>
<span><font color="#888888"><br>
--<br>
Repository URL: <a href="http://hg.python.org/cpython" target="_blank">http://hg.python.org/cpython</a><br>
</font></span><br>_______________________________________________<br>
Python-checkins mailing list<br>
<a href="mailto:Python-checkins@python.org" target="_blank">Python-checkins@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-checkins" target="_blank">http://mail.python.org/mailman/listinfo/python-checkins</a><br>
<br></blockquote></div><br></div></div>