[issue44672] Final "pass" is traced incorrectly in 3.9 (and before)

2021-07-19 Thread Ned Batchelder


Ned Batchelder  added the comment:

This is the right call.  Thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44672] Final "pass" is traced incorrectly in 3.9 (and before)

2021-07-19 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks for reporting, Ned. I agree with Mark though.

We've done 7 releases of Python 3.9 already. The later in the release cycle for 
a given Python version, the less it's clear if it's "worth" performing complex 
fixes. Most importantly because introducing a large functional change at this 
point is risky and we try hard not to disrupt users of stable versions. 
Moreover, our experience shows that later bugfix releases see decreasing 
adoption because by default downstream distributors keep their original early 
bugfix versions of Python with only security- and build-related fixes ported 
from later releases in the same series.

--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44672] Final "pass" is traced incorrectly in 3.9 (and before)

2021-07-19 Thread Mark Shannon

Mark Shannon  added the comment:

I say no, for a couple of reasons.

1. PEP 626 only applies to 3.10 onwards
2. The bytecode optimizer in 3.9 doesn't understand line numbers.
Changing it would be a lot of effort and likely to introduce more bugs than it 
fixes.

Ultimately it is Łukasz's decision, though.

--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44672] Final "pass" is traced incorrectly in 3.9 (and before)

2021-07-19 Thread Ned Batchelder


New submission from Ned Batchelder :

A simple function with a last "pass" statement gets traced incorrectly, 
attributing the return to the pass instead of the actual last statement 
executed:

--- 8< --
import linecache, sys

def trace(frame, event, arg):
# The weird globals here is to avoid a NameError on shutdown...
if frame.f_code.co_filename == globals().get("__file__"):
lineno = frame.f_lineno
print("{} {}: {}".format(event[:4], lineno, linecache.getline(__file__, 
lineno).rstrip()))
return trace

def wrong_loop(x):
if x:
if x:
print(4)
else:
pass

print(sys.version)
sys.settrace(trace)

wrong_loop(8)
--

On 3.9 and before, this produces:

3.9.5 (default, May  5 2021, 06:50:43)
[Clang 12.0.0 (clang-1200.0.32.29)]
call 10: def wrong_loop(x):
line 11: if x:
line 12: if x:
line 13: print(4)
4
line 15: pass
retu 15: pass

Partly I'm writing this issue to record the problem, but partly to get a 
decision: will there be fixes made to 3.9 (or before) for issues like this?

--
components: Interpreter Core
messages: 397791
nosy: Mark.Shannon, nedbat
priority: normal
severity: normal
status: open
title: Final "pass" is traced incorrectly in 3.9 (and before)
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com