Skip to content

f_lineno has different results on Windows and Linux #125422

Closed
@Almenon

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

Metadata

Metadata

Labels

3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions