Message165012
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): |
|
Date |
User |
Action |
Args |
2012-07-08 13:07:16 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, gvanrossum, brett.cannon, georg.brandl, pitrou, Arfrever, r.david.murray, dmalcolm, python-dev |
2012-07-08 13:07:16 | amaury.forgeotdarc | set | messageid: <1341752836.66.0.543191806418.issue15110@psf.upfronthosting.co.za> |
2012-07-08 13:07:16 | amaury.forgeotdarc | link | issue15110 messages |
2012-07-08 13:07:15 | amaury.forgeotdarc | create | |
|