GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-103956: fix `trace` output in case of missing source line by chgnrdv · Pull Request #103958 · python/cpython

Conversation

@chgnrdv

@chgnrdv chgnrdv commented Apr 27, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #103956

  • Issue: trace: line tracing output lacks newlines if source lines are not available #103956

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chgnrdv
Fix Trace.localtrace_trace* output in case of missing source line
589f22f
check if call to `linecache.getline` returns non-empty string
otherwise print only filename with lineno
@bedevere-bot bedevere-bot mentioned this pull request Apr 27, 2023
trace: line tracing output lacks newlines if source lines are not available #103956
Closed
@bedevere-bot bedevere-bot added the awaiting review label Apr 27, 2023
@chgnrdv

chgnrdv commented Apr 27, 2023

Copy link
Copy Markdown
Contributor Author

With this fix the output for frames with missing source files will look like this:

 --- modulename: example, funcname: <module>
example.py(2): import signal
 --- modulename: _bootstrap, funcname: _find_and_load
<frozen importlib._bootstrap>(1299)
<frozen importlib._bootstrap>(1300)
<frozen importlib._bootstrap>(1302)
 --- modulename: _bootstrap, funcname: __init__
<frozen importlib._bootstrap>(325)
<frozen importlib._bootstrap>(326)
 --- modulename: _bootstrap, funcname: __enter__
<frozen importlib._bootstrap>(329)
 --- modulename: _bootstrap, funcname: _get_module_lock
<frozen importlib._bootstrap>(344)
<frozen importlib._bootstrap>(345)
<frozen importlib._bootstrap>(346)
<frozen importlib._bootstrap>(347)
<frozen importlib._bootstrap>(348)
<frozen importlib._bootstrap>(349)
<frozen importlib._bootstrap>(351)
<frozen importlib._bootstrap>(352)
<frozen importlib._bootstrap>(355)
 --- modulename: _bootstrap, funcname: __init__
<frozen importlib._bootstrap>(165)
<frozen importlib._bootstrap>(166)
<frozen importlib._bootstrap>(169)
<frozen importlib._bootstrap>(173)
<frozen importlib._bootstrap>(184)
<frozen importlib._bootstrap>(198)
<frozen importlib._bootstrap>(357)
<frozen importlib._bootstrap>(368)
<frozen importlib._bootstrap>(370)
<frozen importlib._bootstrap>(372)
<frozen importlib._bootstrap>(330)
 --- modulename: _bootstrap, funcname: acquire
<frozen importlib._bootstrap>(222)
<frozen importlib._bootstrap>(223)
 --- modulename: _bootstrap, funcname: __init__
<frozen importlib._bootstrap>(71)
<frozen importlib._bootstrap>(72)
 --- modulename: _bootstrap, funcname: __enter__
<frozen importlib._bootstrap>(82)
<frozen importlib._bootstrap>(83)
<frozen importlib._bootstrap>(224)
<frozen importlib._bootstrap>(228)
<frozen importlib._bootstrap>(229)
<frozen importlib._bootstrap>(236)
<frozen importlib._bootstrap>(237)
<frozen importlib._bootstrap>(238)
<frozen importlib._bootstrap>(228)
<frozen importlib._bootstrap>(223)
 --- modulename: _bootstrap, funcname: __exit__
<frozen importlib._bootstrap>(87)
<frozen importlib._bootstrap>(1303)
<frozen importlib._bootstrap>(1304)
<frozen importlib._bootstrap>(1305)
 --- modulename: _bootstrap, funcname: _find_and_load_unlocked
<frozen importlib._bootstrap>(1250)
<frozen importlib._bootstrap>(1251)
<frozen importlib._bootstrap>(1252)
<frozen importlib._bootstrap>(1253)
<frozen importlib._bootstrap>(1267)
 --- modulename: _bootstrap, funcname: _find_spec
<frozen importlib._bootstrap>(1185)
<frozen importlib._bootstrap>(1186)
<frozen importlib._bootstrap>(1191)
<frozen importlib._bootstrap>(1197)
<frozen importlib._bootstrap>(1198)
<frozen importlib._bootstrap>(1199)
 --- modulename: _bootstrap, funcname: __enter__
<frozen importlib._bootstrap>(1157)
<frozen importlib._bootstrap>(1200)
<frozen importlib._bootstrap>(1201)
<frozen importlib._bootstrap>(1207)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@blurb-it
📜🤖 Added by blurb_it.
83bc542
serhiy-storchaka
serhiy-storchaka reviewed Feb 2, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some tests?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
chgnrdv added 5 commits February 10, 2024 21:23
@chgnrdv
refactor
e840e5f
@chgnrdv
Merge branch 'main' into trace-fix-lacking-newlines
ea443aa
@chgnrdv
Merge branch 'main' into trace-fix-lacking-newlines
095a204
@chgnrdv
added test
f9fffa8
@chgnrdv
Merge branch 'trace-fix-lacking-newlines' of github.com:chgnrdv/cpyth…
7e452a8
…on into trace-fix-lacking-newlines
@chgnrdv

chgnrdv commented Feb 10, 2024

Copy link
Copy Markdown
Contributor Author

It turned out that line tracing isn't tested at all. I will open a separate issue to handle it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka approved these changes Feb 12, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Feb 12, 2024
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) February 12, 2024 11:13
@serhiy-storchaka serhiy-storchaka added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Feb 12, 2024
@chgnrdv
Merge branch 'main' into trace-fix-lacking-newlines
505f4e0
@serhiy-storchaka
serhiy-storchaka merged commit 7c87ce7 into python:main May 9, 2024
@miss-islington-app

miss-islington-app Bot commented May 9, 2024

Copy link
Copy Markdown

Thanks @chgnrdv for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label May 9, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2024
@chgnrdv @miss-islington
pythongh-103956: Fix trace output in case of missing source line (p…
83f2830
…ythonGH-103958)

Print only filename with lineno if linecache.getline() returns an empty string.
(cherry picked from commit 7c87ce7)

Co-authored-by: Radislav Chugunov <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2024
@chgnrdv @miss-islington
pythongh-103956: Fix trace output in case of missing source line (p…
b1b724a
…ythonGH-103958)

Print only filename with lineno if linecache.getline() returns an empty string.
(cherry picked from commit 7c87ce7)

Co-authored-by: Radislav Chugunov <[email protected]>
@bedevere-app

bedevere-app Bot commented May 9, 2024

Copy link
Copy Markdown

GH-118832 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label May 9, 2024
@bedevere-app

bedevere-app Bot commented May 9, 2024

Copy link
Copy Markdown

GH-118833 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label May 9, 2024
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.13 only security fixes label May 9, 2024
@miss-islington-app

miss-islington-app Bot commented May 9, 2024

Copy link
Copy Markdown

Thanks @chgnrdv for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2024
@chgnrdv @miss-islington
pythongh-103956: Fix trace output in case of missing source line (p…
46dd2a7
…ythonGH-103958)

Print only filename with lineno if linecache.getline() returns an empty string.
(cherry picked from commit 7c87ce7)

Co-authored-by: Radislav Chugunov <[email protected]>
@bedevere-app

bedevere-app Bot commented May 9, 2024

Copy link
Copy Markdown

GH-118834 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 9, 2024
@serhiy-storchaka

serhiy-storchaka commented May 9, 2024

Copy link
Copy Markdown
Member

It is too late for the 3.11 backport, but it should now be backported to 3.13.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka pushed a commit that referenced this pull request May 9, 2024
@miss-islington @chgnrdv
[3.12] gh-103956: Fix trace output in case of missing source line (G…
0d62676
…H-103958) (GH-118832)

Print only filename with lineno if linecache.getline() returns an empty string.
(cherry picked from commit 7c87ce7)

Co-authored-by: Radislav Chugunov <[email protected]>
serhiy-storchaka pushed a commit that referenced this pull request May 9, 2024
@miss-islington @chgnrdv
[3.13] gh-103956: Fix trace output in case of missing source line (G…
c4b853f
…H-103958) (GH-118834)

Print only filename with lineno if linecache.getline() returns an empty string.
(cherry picked from commit 7c87ce7)

Co-authored-by: Radislav Chugunov <[email protected]>
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 9, 2024
@chgnrdv @SonicField
pythongh-103956: Fix trace output in case of missing source line (p…
e570920
…ythonGH-103958)

Print only filename with lineno if linecache.getline() returns an empty string.
@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

trace: line tracing output lacks newlines if source lines are not available

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@chgnrdv @serhiy-storchaka @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.