Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f_lineno has different results on Windows and Linux #125422

Closed
Almenon opened this issue Oct 14, 2024 · 5 comments
Closed

f_lineno has different results on Windows and Linux #125422

Almenon opened this issue Oct 14, 2024 · 5 comments
Assignees
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Almenon
Copy link

Almenon commented Oct 14, 2024

Bug report

Bug description:

On Windows 10, f_lineno is 1. On WSL (Ubuntu 20), it is 611. I don't see any mention of cross-platform differences called out in the bdb docs, so I'm wondering if this is a bug.

import bdb

f = {}

class areplDebug(bdb.Bdb):
    # override
    def user_line(self,frame):
        global f
        f = frame

b = areplDebug()
b.run('x=1+5',{},{})

print('frame lineno is ' + str(f.f_lineno)) # 611 on Linux, 1 on Windows 
import linecache
line = linecache.getline(f.f_code.co_filename, f.f_lineno)
print('frame file is: ' + f.f_code.co_filename) # '/home/almenon/.pyenv/versions/3.12.7/lib/python3.12/bdb.py' on Linux,  `<string>` on windows
print('frame line is: ' + line) # '            sys.settrace(None)\n' on Linux, None on Windows

It's not a WSL-specific issue because I'm getting the same error in Github CI. See https://github.com/Almenon/AREPL-backend/actions/runs/11316437382/job/31468723754?pr=193

Reproduction:
Checkout https://github.com/Almenon/AREPL-backend/tree/8aab53e834be9ec4c1a41de08831107446051bc5. Then:

cd AREPL-backend/python
python -m pip install -r requirements.txt
pytest

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

@Almenon Almenon added the type-bug An unexpected behavior, bug, or error label Oct 14, 2024
@Almenon
Copy link
Author

Almenon commented Oct 14, 2024

Another thing I should mention is that Python 3.8 through 3.11 all pass the unit tests in Linux (i.e. f_lineno is 1)

No changes to bdb are mentioned in https://docs.python.org/3/whatsnew/3.12.html, so it's weird that the behavior would change with 3.12

@gaogaotiantian gaogaotiantian self-assigned this Oct 14, 2024
@gaogaotiantian
Copy link
Member

Not all changes were listed on whatsnew :) Sometimes the changes were not user visible, or not important enough to make it (there are a lot of commits to stdlib in a version). This is not super serious but it is something we should fix. I'll work on it.

@Almenon
Copy link
Author

Almenon commented Oct 14, 2024

oh cool, it's an actual bug? This is the first bug I've found in Python :D

What should the desired behavior be? I'm not sure if 611 is correct or 1

@gaogaotiantian
Copy link
Member

It should be 1. 611 is from bdb.py and the user should not receive any events from bdb.py.

@picnixz picnixz added stdlib Python modules in the Lib dir 3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Oct 14, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 15, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 15, 2024
gaogaotiantian added a commit that referenced this issue Oct 15, 2024
…-125427) (#125531)

gh-125422: Don't set the caller's f_trace if it's botframe (GH-125427)
(cherry picked from commit 703227d)

Co-authored-by: Tian Gao <[email protected]>
gaogaotiantian added a commit that referenced this issue Oct 15, 2024
…-125427) (#125530)

gh-125422: Don't set the caller's f_trace if it's botframe (GH-125427)
(cherry picked from commit 703227d)

Co-authored-by: Tian Gao <[email protected]>
@gaogaotiantian
Copy link
Member

Thank you for reporting this, it's fixed in #125427.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants