Skip to content

Commit 9909dea

Browse files
authored
Don't check for frame annotation completeness for Python 3.11 and later (#87)
This PR skips frame annotation completeness tests for Python >= 3.11. Python 3.11 added a reference to the function from the frame (see python/cpython#29595), but didn't expose that reference at Python level.
1 parent d7c3397 commit 9909dea

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

refcycle/test/test_annotations.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ def some_function(x, y):
161161
pow(z, z)
162162
return inspect.currentframe()
163163
frame = some_function("a string", 97.8)
164-
self.check_completeness(frame)
164+
165+
# Python 3.11 adds an f_func (f_funcobj for Python >= 3.12) field to
166+
# the frame struct but doesn't make it accessible / introspectable from
167+
# Python. So we skip the completeness check for Python 3.11 on.
168+
# xref: https://github.com/python/cpython/pull/29595
169+
if sys.version_info < (3, 11):
170+
self.check_completeness(frame)
165171

166172
def test_annotate_frame_with_f_trace(self):
167173
def some_function(x, y):
@@ -178,7 +184,10 @@ def test_trace(frame, event, arg):
178184
frame = some_function("a string", 97.8)
179185
finally:
180186
sys.settrace(old_trace_function)
181-
self.check_completeness(frame)
187+
188+
# See comment for test_annotate_frame above.
189+
if sys.version_info < (3, 11):
190+
self.check_completeness(frame)
182191

183192
def test_annotate_getset_descriptor(self):
184193
class A(object):

0 commit comments

Comments
 (0)