homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients Arfrever, amaury.forgeotdarc, brett.cannon, dmalcolm, georg.brandl, gvanrossum, pitrou, python-dev, r.david.murray
Date 2012年07月08日.13:07:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341752836.66.0.543191806418.issue15110@psf.upfronthosting.co.za>
In-reply-to
Content
I really like the "_exec_module" trick, but it should be applied to builtin modules as well. I hacked _sre.c and got:
~/python/cpython3.x$ ./python 
Traceback (most recent call last):
 File "/home/amauryfa/python/cpython3.x/Lib/site.py", line 70, in <module>
 import re
 File "/home/amauryfa/python/cpython3.x/Lib/re.py", line 122, in <module>
 import sre_compile
 File "/home/amauryfa/python/cpython3.x/Lib/sre_compile.py", line 13, in <module>
 import _sre, sys
 File "<frozen importlib._bootstrap>", line 1318, in _find_and_load
 File "<frozen importlib._bootstrap>", line 1285, in _find_and_load_unlocked
 File "<frozen importlib._bootstrap>", line 347, in set_package_wrapper
 File "<frozen importlib._bootstrap>", line 360, in set_loader_wrapper
 File "<frozen importlib._bootstrap>", line 443, in _requires_builtin_wrapper
 File "<frozen importlib._bootstrap>", line 493, in load_module
ValueError: Just a test
This change correctly hides importlib frames:
diff -r 9afdd8c25bf2 Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py	Sun Jul 08 14:00:06 2012 +0200
+++ b/Lib/importlib/_bootstrap.py	Sun Jul 08 15:03:27 2012 +0200
@@ -490,12 +490,15 @@
 """Load a built-in module."""
 is_reload = fullname in sys.modules
 try:
- return _imp.init_builtin(fullname)
+ return self._exec_module(fullname)
 except:
 if not is_reload and fullname in sys.modules:
 del sys.modules[fullname]
 raise
 
+ def _exec_module(self, fullname):
+ return _imp.init_builtin(fullname)
+
 @classmethod
 @_requires_builtin
 def get_code(cls, fullname):
History
Date User Action Args
2012年07月08日 13:07:16amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, gvanrossum, brett.cannon, georg.brandl, pitrou, Arfrever, r.david.murray, dmalcolm, python-dev
2012年07月08日 13:07:16amaury.forgeotdarcsetmessageid: <1341752836.66.0.543191806418.issue15110@psf.upfronthosting.co.za>
2012年07月08日 13:07:16amaury.forgeotdarclinkissue15110 messages
2012年07月08日 13:07:15amaury.forgeotdarccreate

AltStyle によって変換されたページ (->オリジナル) /