[pypy-commit] pypy less-stringly-ops: kill FlowObjSpace.unpackiterable()

rlamy noreply at buildbot.pypy.org
Sun Sep 22 21:24:53 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: less-stringly-ops
Changeset: r67061:199438138ea5
Date: 2013-09-22 07:53 +0100
http://bitbucket.org/pypy/pypy/changeset/199438138ea5/

Log:	kill FlowObjSpace.unpackiterable()

diff --git a/rpython/flowspace/argument.py b/rpython/flowspace/argument.py
--- a/rpython/flowspace/argument.py
+++ b/rpython/flowspace/argument.py
@@ -1,7 +1,7 @@
 """
 Arguments objects.
 """
-
+from rpython.flowspace.model import const
 
 class Signature(object):
     _immutable_ = True
@@ -95,3 +95,10 @@
         if shape_star:
             data_w.append(self.w_stararg)
         return (shape_cnt, shape_keys, shape_star, shape_stst), data_w
+
+    def as_list(self):
+        assert not self.keywords
+        if self.w_stararg is None:
+            return self.arguments_w
+        else:
+            return self.arguments_w + [const(x) for x in self.w_stararg.value]
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -8,8 +8,8 @@
 from inspect import CO_NEWLOCALS
 
 from rpython.flowspace.argument import CallSpec
-from rpython.flowspace.model import (Constant, Variable, WrapException,
-    UnwrapException, checkgraph, const, FSException)
+from rpython.flowspace.model import (Constant, Variable, checkgraph, const,
+    FSException)
 from rpython.flowspace.bytecode import HostCode
 from rpython.flowspace.operation import op, NOT_REALLY_CONST
 from rpython.flowspace.flowcontext import (FlowSpaceFrame, fixeggblocks,
@@ -121,8 +121,8 @@
             w_real_class = const(rstackovf._StackOverflow)
             return frame.guessbool(self.issubtype(w_exc_type, w_real_class))
         # checking a tuple of classes
-        for w_klass in self.unpackiterable(w_check_class):
-            if self.exception_match(w_exc_type, w_klass):
+        for klass in w_check_class.value:
+            if self.exception_match(w_exc_type, const(klass)):
                 return True
         return False
 
@@ -157,13 +157,6 @@
         w_type = self.type(w_value)
         return FSException(w_type, w_value)
 
-    def unpackiterable(self, w_iterable):
-        if isinstance(w_iterable, Constant):
-            l = w_iterable.value
-            return [const(x) for x in l]
-        else:
-            raise UnwrapException("cannot unpack a Variable iterable ")
-
     def unpack_sequence(self, w_iterable, expected_length):
         if isinstance(w_iterable, Constant):
             l = list(w_iterable.value)
@@ -183,7 +176,6 @@
     def not_(self, w_obj):
         return const(not self.frame.guessbool(self.bool(w_obj)))
 
-
     def import_name(self, name, glob=None, loc=None, frm=None, level=-1):
         try:
             mod = __import__(name, glob, loc, frm, level)
@@ -229,23 +221,18 @@
             except (KeyError, TypeError):
                 pass
             else:
-                assert args.keywords == {}, "should not call %r with keyword arguments" % (fn,)
-                if args.w_stararg is not None:
-                    args_w = args.arguments_w + self.unpackiterable(args.w_stararg)
-                else:
-                    args_w = args.arguments_w
-                return sc(self, *args_w)
+                if args.keywords:
+                    raise FlowingError(
+                        "should not call %r with keyword arguments" % (fn,))
+                return sc(self, *args.as_list())
 
         if args.keywords or isinstance(args.w_stararg, Variable):
             shape, args_w = args.flatten()
             w_res = self.frame.do_operation('call_args', w_callable,
                     Constant(shape), *args_w)
         else:
-            if args.w_stararg is not None:
-                args_w = args.arguments_w + self.unpackiterable(args.w_stararg)
-            else:
-                args_w = args.arguments_w
-            w_res = self.frame.do_operation('simple_call', w_callable, *args_w)
+            w_res = self.frame.do_operation(
+                    'simple_call', w_callable, *args.as_list())
         self.frame.guessexception(self._callable_exceptions(w_callable))
         return w_res
 
@@ -261,7 +248,6 @@
         # *any* exception for non-builtins
         return [Exception]
 
-
     def find_global(self, w_globals, varname):
         try:
             value = w_globals.value[varname]


More information about the pypy-commit mailing list