Closed gitlab-importer closed 9 months ago
In Heptapod by @arigo on Jan 1, 2020, 19:33
I think this is an irrelevant detail. The reason for why the line is missing is because the default argument is found to be a constant in pypy3 7.3.0, but not in pypy3 7.2.0. The following two examples give the same result in each case:
#!python
@foo
def f(x): # this line not included by dis
pass
#!python
@foo
def f(x=y): # this line IS included by dis
pass
But the following code gives a different result:
#!python
@foo
def f(x=25):
pass
The difference is only that this last piece of code compiles like the first one above in 7.3.0 (because the constant 25 doesn't really need line numbers, as it cannot fail), whereas it used to compile like the 2nd one above in 7.2.0 (because it used to involve a BUILD_TUPLE, which could fail).
I think the difference is only caused by removing pointless, never-executed line numbers.
If I'm wrong, I can be convinced with another example.
In Heptapod by bitbucket_importer on Jan 6, 2020, 12:48
Created originally on Bitbucket by ned (Ned Batchelder)
Thanks for the explanation. I follow these details because coverage.py needs to understand what lines could be traced. I write these bugs to be sure the language devs know the change has happened.
In Heptapod by @arigo on Jan 6, 2020, 17:52
Found out how CPython 3.6.9 does it and copied it exactly in d36692105171: it emits the lineno of the last item of the tuple when the tuple of defaults is a constant.
In Heptapod by bitbucket_importer on Dec 31, 2019, 16:06
Created originally on Bitbucket by ned (Ned Batchelder)
The line numbers compiled into code objects has changed for decorated functions
In 7.2.0, the def line was included for decorated functions. In 7.3.0, the def line is not included. Decorated methods include the def line in all versions.
CPython has always included the def line for decorated functions. For decorated methods, they changed in 3.8 to include the def line for decorated methods also.
CPython changed their behavior in Python 3.8 to include the def line for methods, but not functions.
Here’s a test case. dis shows the line numbers along the left. 7.3.0 is missing line numbers 5 and 25: