File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -535,10 +535,14 @@ def returns_value(func):
535
535
# returns are of the form "return" or "return None". The
536
536
# latter is a false negative, but cannot be avoided with
537
537
# bytecode inspection.
538
+ # XXX: This will give a false positive for functions
539
+ # that only contain "return None" paths for
540
+ # returning a value.
538
541
if not isinstance (func .__code__ , types .CodeType ):
539
542
return True
540
543
541
544
prev = None
545
+
542
546
for inst in dis .get_instructions (func ):
543
547
if inst .opname == "RETURN_VALUE" :
544
548
assert prev is not None
@@ -549,9 +553,6 @@ def returns_value(func):
549
553
550
554
elif inst .opname == "RETURN_CONST" and inst .arg != 0 :
551
555
# 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.
555
556
return True
556
557
prev = inst
557
558
Original file line number Diff line number Diff line change @@ -2349,7 +2349,7 @@ def func():
2349
2349
2350
2350
self .assertFalse (_transform .returns_value (func ))
2351
2351
2352
- @expectedFailureIf (sys .version_info [:2 ] >= (3 , 12 ))
2352
+ @expectedFailureIf (sys .version_info [:2 ] >= (3 , 8 ))
2353
2353
def test_returns_None (self ):
2354
2354
with self .subTest ("function returns constant value" ):
2355
2355
You can’t perform that action at this time.
0 commit comments