Author: Philip Jenvey <pjen...@underboss.org>
Branch: stdlib-2.7.12
Changeset: r87649:b6a53a02b992
Date: 2016-10-08 20:21 -0700
http://bitbucket.org/pypy/pypy/changeset/b6a53a02b992/

Log:    avoid GeneratorIterator blowing up pypyjit's ztranslation (from
        argument.py, sigh)

diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -89,9 +89,8 @@
         try:
             args_w = space.fixedview(w_stararg)
         except OperationError as e:
-            from pypy.interpreter.generator import GeneratorIterator
             if (e.match(space, space.w_TypeError) and
-                    not isinstance(w_stararg, GeneratorIterator)):
+                    not space.is_generator(w_stararg)):
                 raise oefmt(space.w_TypeError,
                             "argument after * must be an iterable, not %T",
                             w_stararg)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -857,13 +857,11 @@
         Raise an OperationError(w_ValueError) if the length is wrong."""
         w_iterator = self.iter(w_iterable)
         if expected_length == -1:
-            # xxx special hack for speed
-            from pypy.interpreter.generator import GeneratorIterator
-            if isinstance(w_iterator, GeneratorIterator):
+            if self.is_generator(w_iterator):
+                # special hack for speed
                 lst_w = []
                 w_iterator.unpack_into(lst_w)
                 return lst_w
-            # /xxx
             return self._unpackiterable_unknown_length(w_iterator, w_iterable)
         else:
             lst_w = self._unpackiterable_known_length(w_iterator,
@@ -1180,6 +1178,10 @@
         from pypy.module.__builtin__.interp_classobj import W_InstanceObject
         return isinstance(w_obj, W_InstanceObject)
 
+    def is_generator(self, w_obj):
+        from pypy.interpreter.generator import GeneratorIterator
+        return isinstance(w_obj, GeneratorIterator)
+
     def callable(self, w_obj):
         if self.lookup(w_obj, "__call__") is not None:
             if self.is_oldstyle_instance(w_obj):
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -333,6 +333,9 @@
     def _try_fetch_pycode(self, w_func):
         return None
 
+    def is_generator(self, w_obj):
+        return NonConstant(False)
+
     # ----------
 
     def translates(self, func=None, argtypes=None, seeobj_w=[], **kwds):
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -21,7 +21,6 @@
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import (
     WrappedDefault, applevel, interp2app, unwrap_spec)
-from pypy.interpreter.generator import GeneratorIterator
 from pypy.interpreter.signature import Signature
 from pypy.interpreter.typedef import TypeDef
 from pypy.objspace.std.bytesobject import W_BytesObject
@@ -863,7 +862,7 @@
         if type(w_any) is W_ListObject or (isinstance(w_any, W_ListObject) and
                                            self.space._uses_list_iter(w_any)):
             self._extend_from_list(w_list, w_any)
-        elif isinstance(w_any, GeneratorIterator):
+        elif space.is_generator(w_any):
             w_any.unpack_into_w(w_list)
         else:
             self._extend_from_iterable(w_list, w_any)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to