Closed pablogsal closed 3 years ago
I have noticed that the semantics of PyCode_Addr2Line() have changed from 3.9 to 3.10. Technically, the function was called with:
PyCode_Addr2Line(frame->f_code, frame->f_last_i * 2)
but now it needs to be called with
PyCode_Addr2Line(frame->f_code, frame->f_last_i * 2)
This is likely going to break all users of this function. This is also not advertised in the 3.10 "how to port to Python 3.10" section.
We should discuss what's the best approach here because technically this is a backwards incompatible change, although in the other hand PyCode_Addr2Line() was not documented previously so we may have some room.
We need to decide on this ASAP, because there is only one extra release candidate before the actual release of 3.10/
Sorry, bad copy paste. Correction:
Technically, the function was called with:
PyCode_Addr2Line(frame->f_code, frame->f_last_i)
but now it needs to be called with
PyCode_Addr2Line(frame->f_code, frame->f_last_i * 2)
It is not PyCode_Addr2Line()
that has changed, but frame->f_lasti
.
If you call
PyCode_Addr2Line(frame->f_code, 8)
in 3.9
you get the same behavior as calling
PyCode_Addr2Line(frame->f_code, 8)
in 3.10.
Assuming the bytecode is unchanged.
The difference is that for the nth instruction frame->f_lasti
is n*2 for 3.9 and n for 3.10.
People should be using PyFrame_GetLineNumber()
, which is part of the API.
Are you ok if I add a small comment to the what's new of 3.10?
New changeset fa2c0b85a8d5c9486661083afdf38cbaadb3432a by Pablo Galindo Salgado in branch 'main': bpo-44964: Add a note explaining the new semantics of f_last_i in frame objects (GH-28200) https://github.com/python/cpython/commit/fa2c0b85a8d5c9486661083afdf38cbaadb3432a
New changeset fc840736e54da0557616882012f362b809490165 by Miss Islington (bot) in branch '3.10': bpo-44964: Add a note explaining the new semantics of f_last_i in frame objects (GH-28200) https://github.com/python/cpython/commit/fc840736e54da0557616882012f362b809490165
New changeset ab327f2929589407595a3de95727c8ab34ddd4af by Pablo Galindo Salgado in branch 'main': bpo-44964: Correct the note about the f_lasti field (GH-28208) https://github.com/python/cpython/commit/ab327f2929589407595a3de95727c8ab34ddd4af
New changeset b045174a6dbf1060f092265853f0c78f0704a21a by Miss Islington (bot) in branch '3.10': bpo-44964: Correct the note about the f_lasti field (GH-28208) (GH-28276) https://github.com/python/cpython/commit/b045174a6dbf1060f092265853f0c78f0704a21a
New changeset 490a7427dce1cba55a9fbdbccd092e4c8ffae05f by Pablo Galindo (Miss Islington (bot)) in branch '3.10': bpo-44964: Correct the note about the f_lasti field (GH-28208) (GH-28276) https://github.com/python/cpython/commit/490a7427dce1cba55a9fbdbccd092e4c8ffae05f
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at =
created_at =
labels = ['release-blocker', '3.10', '3.11']
title = 'Semantics of PyCode_Addr2Line() changed'
updated_at =
user = 'https://github.com/pablogsal'
```
bugs.python.org fields:
```python
activity =
actor = 'pablogsal'
assignee = 'none'
closed = True
closed_date =
closer = 'pablogsal'
components = []
creation =
creator = 'pablogsal'
dependencies = []
files = []
hgrepos = []
issue_num = 44964
keywords = ['patch', '3.10regression']
message_count = 9.0
messages = ['399985', '399986', '400033', '400035', '401239', '401243', '401585', '401589', '403175']
nosy_count = 4.0
nosy_names = ['lukasz.langa', 'Mark.Shannon', 'pablogsal', 'miss-islington']
pr_nums = ['28200', '28202', '28208', '28276']
priority = 'release blocker'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue44964'
versions = ['Python 3.10', 'Python 3.11']
```