[pypy-commit] pypy translation-cleanup: Disable non-working PRINT_* opcodes, with test
rlamy
noreply at buildbot.pypy.org
Thu Sep 27 19:42:15 CEST 2012
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57633:621474d4d149
Date: 2012-09-27 18:41 +0100
http://bitbucket.org/pypy/pypy/changeset/621474d4d149/
Log: Disable non-working PRINT_* opcodes, with test
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -468,6 +468,9 @@
next_instr = block.handle(self, unroller)
return next_instr
+ def BAD_OPCODE(self, _, next_instr):
+ raise FlowingError(self, "This operation is not RPython")
+
def BREAK_LOOP(self, oparg, next_instr):
return self.unrollstack_and_jump(SBreakLoop.singleton)
@@ -576,28 +579,15 @@
# isn't popped straightaway.
self.pushvalue(None)
- def PRINT_EXPR(self, oparg, next_instr):
- w_expr = self.popvalue()
- print_expr(self.space, w_expr)
-
- def PRINT_ITEM_TO(self, oparg, next_instr):
- w_stream = self.popvalue()
- w_item = self.popvalue()
- if self.space.is_w(w_stream, self.space.w_None):
- w_stream = sys_stdout(self.space) # grumble grumble special cases
- print_item_to(self.space, w_item, w_stream)
+ PRINT_EXPR = BAD_OPCODE
+ PRINT_ITEM_TO = BAD_OPCODE
+ PRINT_NEWLINE_TO = BAD_OPCODE
def PRINT_ITEM(self, oparg, next_instr):
w_item = self.popvalue()
w_s = self.space.do_operation('str', w_item)
self.space.appcall(rpython_print_item, w_s)
- def PRINT_NEWLINE_TO(self, oparg, next_instr):
- w_stream = self.popvalue()
- if self.space.is_w(w_stream, self.space.w_None):
- w_stream = sys_stdout(self.space) # grumble grumble special cases
- print_newline_to(self.space, w_stream)
-
def PRINT_NEWLINE(self, oparg, next_instr):
self.space.appcall(rpython_print_newline)
diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -100,6 +100,11 @@
def test_print(self):
x = self.codetest(self.print_)
+ def test_bad_print(self):
+ def f(x):
+ print >> x, "Hello"
+ with py.test.raises(FlowingError):
+ self.codetest(f)
#__________________________________________________________
def while_(i):
while i > 0:
More information about the pypy-commit
mailing list