Skip to content

Commit 51d91a5

Browse files
Minor tweak in detection of return values.
1 parent 966ddd0 commit 51d91a5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pyobjc-core/Lib/objc/_transform.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,14 @@ def returns_value(func):
535535
# returns are of the form "return" or "return None". The
536536
# latter is a false negative, but cannot be avoided with
537537
# bytecode inspection.
538+
# XXX: This will give a false positive for functions
539+
# that only contain "return None" paths for
540+
# returning a value.
538541
if not isinstance(func.__code__, types.CodeType):
539542
return True
540543

541544
prev = None
545+
542546
for inst in dis.get_instructions(func):
543547
if inst.opname == "RETURN_VALUE":
544548
assert prev is not None
@@ -549,9 +553,6 @@ def returns_value(func):
549553

550554
elif inst.opname == "RETURN_CONST" and inst.arg != 0:
551555
# New in Python 3.12.
552-
# XXX: This will give a false positive for functions
553-
# that only contain "return None" paths for
554-
# returning a value.
555556
return True
556557
prev = inst
557558

pyobjc-core/PyObjCTest/test_transform.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2349,7 +2349,7 @@ def func():
23492349

23502350
self.assertFalse(_transform.returns_value(func))
23512351

2352-
@expectedFailureIf(sys.version_info[:2] >= (3, 12))
2352+
@expectedFailureIf(sys.version_info[:2] >= (3, 8))
23532353
def test_returns_None(self):
23542354
with self.subTest("function returns constant value"):
23552355

0 commit comments

Comments
 (0)