Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r56795:9cd3aff99129
Date: 2012-08-22 12:06 +0200
http://bitbucket.org/pypy/pypy/changeset/9cd3aff99129/

Log:    tentative rpython fixes

diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -5,6 +5,7 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.rlib.debug import make_sure_not_resized
 from pypy.rlib import jit
+from pypy.rlib.debug import check_annotation
 from pypy.rlib.objectmodel import enforceargs
 
 class Signature(object):
@@ -92,15 +93,19 @@
         raise IndexError
 
 
-def assert_list_of_unicode(value):
-    from pypy.rlib.debug import check_annotation
-    def checker(ann, bk):
-        from pypy.annotation.model import SomeList, SomeUnicodeString
-        if not isinstance(ann, SomeList):
-            raise TypeError
-        if not isinstance(ann.listdef.listitem.s_value, SomeUnicodeString):
-            raise TypeError
-    check_annotation(value, checker)
+
+def check_list_of_unicode(ann, bk):
+    from pypy.annotation.model import (SomeList, SomeUnicodeString,
+                                       s_None, s_ImpossibleValue)
+    if ann is s_None:
+        return
+    if not isinstance(ann, SomeList):
+        raise TypeError
+    s_item = ann.listdef.listitem.s_value
+    if s_item is s_ImpossibleValue:
+        return
+    if not isinstance(s_item, SomeUnicodeString):
+        raise TypeError
 
 
 class Arguments(object):
@@ -121,7 +126,7 @@
         self.space = space
         assert isinstance(args_w, list)
         self.arguments_w = args_w
-        assert_list_of_unicode(keywords)
+        check_annotation(keywords, check_list_of_unicode)
         
         self.keywords = keywords
         self.keywords_w = keywords_w
@@ -197,7 +202,7 @@
         # unpack the ** arguments
         space = self.space
         keywords, values_w = space.view_as_kwargs(w_starstararg)
-        assert_list_of_unicode(keywords)
+        check_annotation(keywords, check_list_of_unicode)
         if keywords is not None: # this path also taken for empty dicts
             if self.keywords is None:
                 self.keywords = keywords
diff --git a/pypy/module/__builtin__/compiling.py 
b/pypy/module/__builtin__/compiling.py
--- a/pypy/module/__builtin__/compiling.py
+++ b/pypy/module/__builtin__/compiling.py
@@ -6,7 +6,7 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.astcompiler import consts, ast
 from pypy.interpreter.gateway import unwrap_spec
-from pypy.interpreter.argument import Arguments, assert_list_of_unicode
+from pypy.interpreter.argument import Arguments, check_annotation, 
check_list_of_unicode
 from pypy.interpreter.nestedscope import Cell
 
 @unwrap_spec(filename=str, mode=str, flags=int, dont_inherit=int, optimize=int)
@@ -114,7 +114,7 @@
 def build_class(space, w_func, w_name, __args__):
     bases_w, kwds_w = __args__.unpack()
     w_bases = space.newtuple(bases_w)
-    w_meta = kwds_w.pop('metaclass', None)
+    w_meta = kwds_w.pop(u'metaclass', None)
     if w_meta is None:
         if bases_w:
             w_meta = space.type(bases_w[0])
@@ -129,7 +129,7 @@
         w_namespace = space.newdict()
     else:
         keywords = kwds_w.keys()
-        assert_list_of_unicode(keywords)
+        check_annotation(keywords, check_list_of_unicode)
         args = Arguments(space, 
                          args_w=[w_name, w_bases],
                          keywords=keywords,
@@ -137,7 +137,7 @@
         w_namespace = space.call_args(w_prep, args)
     w_cell = space.call_function(w_func, w_namespace)
     keywords = kwds_w.keys()
-    assert_list_of_unicode(keywords)
+    check_annotation(keywords, check_list_of_unicode)
     args = Arguments(space,
                      args_w=[w_name, w_bases, w_namespace],
                      keywords=keywords,
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to