Commits

Ronan Lamy committed 1994381

kill FlowObjSpace.unpackiterable()

Comments (0)

Files changed (2)

rpython/flowspace/argument.py

 """
 Arguments objects.
 """
-
+from rpython.flowspace.model import const
 
 class Signature(object):
     _immutable_ = True
         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]

rpython/flowspace/objspace.py

 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,
             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
 
         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)
     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)
             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
 
         # *any* exception for non-builtins
         return [Exception]
 
-
     def find_global(self, w_globals, varname):
         try:
             value = w_globals.value[varname]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.