Author: Stephan <step...@stzal.com> Branch: Changeset: r313:2c028cb476fd Date: 2012-12-11 16:29 +0100 http://bitbucket.org/pypy/lang-js/changeset/2c028cb476fd/
Log: assert unicode identifiers diff --git a/js/environment_record.py b/js/environment_record.py --- a/js/environment_record.py +++ b/js/environment_record.py @@ -87,6 +87,7 @@ # 10.2.1.1.2 def create_mutuable_binding(self, identifier, deletable): + assert identifier is not None and isinstance(identifier, unicode) assert not self.has_binding(identifier) self._add_binding(identifier, w_Undefined) self._set_mutable_binding(identifier) @@ -95,7 +96,7 @@ # 10.2.1.1.3 def set_mutable_binding(self, identifier, value, strict): - #assert isinstance(identifier, unicode) + assert identifier is not None and isinstance(identifier, unicode) assert self.has_binding(identifier) if not self._is_mutable_binding(identifier): from js.execution import JsTypeError @@ -104,11 +105,13 @@ # 10.2.1.1.4 def get_binding_value(self, identifier, strict=False): + assert identifier is not None and isinstance(identifier, unicode) assert self.has_binding(identifier) return self._get_binding(identifier) # 10.2.1.1.5 def delete_binding(self, identifier): + assert identifier is not None and isinstance(identifier, unicode) if not self.has_binding(identifier): return True if self._is_mutable_binding(identifier) is False: @@ -144,11 +147,13 @@ # 10.2.1.2.1 def has_binding(self, n): + assert n is not None and isinstance(n, unicode) bindings = self.binding_object return bindings.has_property(n) # 10.2.1.2.2 def create_mutuable_binding(self, n, d): + assert n is not None and isinstance(n, unicode) bindings = self.binding_object assert bindings.has_property(n) is False if d is True: @@ -162,12 +167,13 @@ # 10.2.1.2.3 def set_mutable_binding(self, n, v, s): - #assert isinstance(n, unicode) + assert n is not None and isinstance(n, unicode) bindings = self.binding_object bindings.put(n, v, s) # 10.2.1.2.4 def get_binding_value(self, n, s=False): + assert n is not None and isinstance(n, unicode) bindings = self.binding_object value = bindings.has_property(n) if value is False: @@ -181,6 +187,7 @@ # 10.2.1.2.5 def delete_binding(self, n): + assert n is not None and isinstance(n, unicode) bindings = self.binding_object return bindings.delete(n, False) diff --git a/js/functions.py b/js/functions.py --- a/js/functions.py +++ b/js/functions.py @@ -51,6 +51,7 @@ _immutable_fields_ = ['_name_', '_function_'] def __init__(self, function, name=u''): + assert isinstance(name, unicode) self._name_ = name self._function_ = function @@ -79,6 +80,7 @@ _immutable_fields_ = ['_name_', '_intimate_function_'] def __init__(self, function, name=u''): + assert isinstance(name, unicode) self._name_ = name self._intimate_function_ = function @@ -151,6 +153,7 @@ _immutable_fields_ = ['_js_code_', '_stack_size_', '_symbol_size_', '_name_'] def __init__(self, name, js_code): + assert isinstance(name, unicode) JsExecutableCode.__init__(self, js_code) self._name_ = name diff --git a/js/jscode.py b/js/jscode.py --- a/js/jscode.py +++ b/js/jscode.py @@ -242,7 +242,7 @@ result = opcode.eval(ctx) if debug: - d = '%s\t%s' % (str(pc), str(opcode)) + d = u'%s\t%s' % (unicode(str(pc)), unicode(str(opcode))) #d = u'%s' % (unicode(str(pc))) #d = u'%3d %25s %s %s' % (pc, unicode(opcode), unicode([unicode(s) for s in ctx._stack_]), unicode(result)) print(d) diff --git a/js/jsobj.py b/js/jsobj.py --- a/js/jsobj.py +++ b/js/jsobj.py @@ -285,7 +285,6 @@ # 8.12.5 def put(self, p, v, throw=False): - #assert isinstance(p, unicode) assert p is not None and isinstance(p, unicode) if self.can_put(p) is False: @@ -342,7 +341,6 @@ # 8.12.6 def has_property(self, p): - #assert isinstance(p, unicode) assert p is not None and isinstance(p, unicode) desc = self.get_property(p) @@ -1318,7 +1316,6 @@ # 4 elif is_array_index(p): - #assert isinstance(p, unicode) assert p is not None and isinstance(p, unicode) # a diff --git a/js/lexical_environment.py b/js/lexical_environment.py --- a/js/lexical_environment.py +++ b/js/lexical_environment.py @@ -2,6 +2,7 @@ def get_identifier_reference(lex, identifier, strict=False): + assert isinstance(identifier, unicode) if lex is None: return Reference(referenced=identifier, strict=strict) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit