[pypy-svn] r29748 - in pypy/dist/pypy: interpreter module/recparser/test
mwh at codespeak.net
mwh at codespeak.net
Fri Jul 7 16:42:30 CEST 2006
Author: mwh
Date: Fri Jul 7 16:42:26 2006
New Revision: 29748
Modified:
pypy/dist/pypy/interpreter/pycompiler.py
pypy/dist/pypy/module/recparser/test/test_compilehooks.py
Log:
(misto, mwh)
Remove broken compiler hooks.
Modified: pypy/dist/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycompiler.py (original)
+++ pypy/dist/pypy/interpreter/pycompiler.py Fri Jul 7 16:42:26 2006
@@ -221,10 +221,14 @@
e.wrap_info(space, filename))
if not space.is_w(self.w_compile_hook, space.w_None):
- w_ast_tree = space.call_function(self.w_compile_hook,
- space.wrap(ast_tree),
- space.wrap(encoding))
- ast_tree = space.interp_w(Node, w_ast_tree)
+ try:
+ w_ast_tree = space.call_function(self.w_compile_hook,
+ space.wrap(ast_tree),
+ space.wrap(encoding))
+ ast_tree = space.interp_w(Node, w_ast_tree)
+ except OperationError:
+ self.w_compile_hook = space.w_None
+ raise
try:
astcompiler.misc.set_filename(filename, ast_tree)
flag_names = get_flag_names(space, flags)
Modified: pypy/dist/pypy/module/recparser/test/test_compilehooks.py
==============================================================================
--- pypy/dist/pypy/module/recparser/test/test_compilehooks.py (original)
+++ pypy/dist/pypy/module/recparser/test/test_compilehooks.py Fri Jul 7 16:42:26 2006
@@ -27,6 +27,21 @@
exec "a = 3" in d
assert d['a'] == 2 # well, yes ...
+ def test_removal_of_broken_hooks(self):
+ def hook(ast, enc):
+ 1/0
+ import parser
+ parser.install_compiler_hook(hook)
+ raises(ZeroDivisionError, "eval('1')")
+ assert eval("1") == 1
+
+ def hook2(ast, enc):
+ return 1
+ parser.install_compiler_hook(hook2)
+ raises(TypeError, "eval('2')")
+ assert eval("2") == 2
+
+
class DISABLEDAppTest_GlobalsAsConsts:
def test_ast_parser(self):
More information about the Pypy-commit
mailing list