Skip to content

f_lineno has different results on Windows and Linux #125422

Closed

Description

@Almenon

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

Activity

  1. Almenon commented on Oct 14, 2024

    @Almenon
    Author

    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

  2. gaogaotiantian commented on Oct 14, 2024

    @gaogaotiantian
    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.

  3. Almenon commented on Oct 14, 2024

    @Almenon
    Author

    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

  4. gaogaotiantian commented on Oct 14, 2024

    @gaogaotiantian
    Member

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

  5. added
    stdlibStandard Library Python modules in the Lib/ directory
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    on Oct 14, 2024
  6. added a commit that references this issue on Oct 15, 2024
  7. added 2 commits that reference this issue on Oct 15, 2024
  8. added 2 commits that reference this issue on Oct 15, 2024
  9. gaogaotiantian commented on Oct 15, 2024

    @gaogaotiantian
    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

Metadata

Metadata

Labels

3.12only security fixes3.13only security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions