[pypy-commit] lang-js default: do not allow this in for-in

stepahn noreply at buildbot.pypy.org
Fri Dec 28 11:35:29 CET 2012


Author: Stephan <stephan at stzal.com>
Branch: 
Changeset: r307:49538e407502
Date: 2012-12-11 12:19 +0100
http://bitbucket.org/pypy/lang-js/changeset/49538e407502/

Log:	do not allow this in for-in

diff --git a/js/execution.py b/js/execution.py
--- a/js/execution.py
+++ b/js/execution.py
@@ -29,8 +29,15 @@
 
 
 class JsException(Exception):
+    message = u'Exception'
+
+    def __init__(self, message=None):
+        if message is not None:
+            assert isinstance(message, unicode)
+            self.message = message
+
     def _msg(self):
-        return u'Exception'
+        return self.message
 
     def msg(self):
         from js.jsobj import _w
diff --git a/js/operations.py b/js/operations.py
--- a/js/operations.py
+++ b/js/operations.py
@@ -4,7 +4,7 @@
 Implements the javascript operations nodes for the interpretation tree
 """
 
-from js.execution import JsTypeError
+from js.execution import JsTypeError, JsException
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.objectmodel import enforceargs
 
@@ -989,6 +989,8 @@
         bytecode.emit('NEXT_ITERATOR')
 
         # store iterrator value into approperiate place
+        if isinstance(left_expr, This):
+            raise JsException(u'Invalid left-hand side in for-in')
         if isinstance(left_expr, Identifier):
             name = left_expr.name
             index = left_expr.index


More information about the pypy-commit mailing list