[pypy-commit] pypy default: Issue #2628

arigo pypy.commits at gmail.com
Sat Sep 23 08:43:59 EDT 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r92447:167b802baf3b
Date: 2017-09-23 14:43 +0200
http://bitbucket.org/pypy/pypy/changeset/167b802baf3b/

Log:	Issue #2628

	Take the 'fake_frame' objects returned by sys._current_frames() on
	PyPy, and make inspect.isframe() return True on them. This lets a
	few more inspect functions work with them.

diff --git a/lib-python/2.7/inspect.py b/lib-python/2.7/inspect.py
--- a/lib-python/2.7/inspect.py
+++ b/lib-python/2.7/inspect.py
@@ -203,7 +203,7 @@
         f_locals        local namespace seen by this frame
         f_restricted    0 or 1 if frame is in restricted execution mode
         f_trace         tracing function for this frame, or None"""
-    return isinstance(object, types.FrameType)
+    return isinstance(object, (types.FrameType, types.FakeFrameType))
 
 def iscode(object):
     """Return true if the object is a code object.
diff --git a/lib-python/2.7/types.py b/lib-python/2.7/types.py
--- a/lib-python/2.7/types.py
+++ b/lib-python/2.7/types.py
@@ -71,6 +71,12 @@
     FrameType = type(tb.tb_frame)
     del tb
 
+# PyPy extension
+try:
+    FakeFrameType = type(next(sys._current_frames().itervalues()))
+except AttributeError:
+    FakeFrameType = FrameType
+
 SliceType = slice
 EllipsisType = type(Ellipsis)
 


More information about the pypy-commit mailing list