Skip to content

inspect.{getsourcelines, findsource} return 0 as the starting line number for modules #103319

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

Open
artemmukhin opened this issue Apr 6, 2023 · 0 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@artemmukhin
Copy link
Contributor

artemmukhin commented Apr 6, 2023

Bug report

Run the following program

import inspect
import inspect
_, lineno1 = inspect.getsourcelines(inspect.currentframe())
_, lineno2 = inspect.findsource(inspect.currentframe())
print(lineno1, lineno2)

Expected Result
The line numbers are expected to be 1-based, so the expected output is 1 1.

Actual Result
The actual output is 0 0.

Related discussion: #103226

Your environment

  • CPython versions tested on: main branch
  • Operating system and architecture: macOS

Linked PRs

@artemmukhin artemmukhin added the type-bug An unexpected behavior, bug, or error label Apr 6, 2023
@artemmukhin artemmukhin changed the title inspect.getsourcelines returns 0 as the starting line number for modules inspect.{getsourcelines, findsource} return 0 as the starting line number for modules Apr 6, 2023
@AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants