FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-103956: fix `trace` output in case of missing source line by chgnrdv · Pull Request #103958 · python/cpython · GitHub

/ cpython Public

gh-103956: fix trace output in case of missing source line - #103958

Merged
serhiy-storchaka merged 8 commits into
python:mainfrom
chgnrdv:trace-fix-lacking-newlines
May 9, 2024
Merged

gh-103956: fix trace output in case of missing source line#103958
serhiy-storchaka merged 8 commits into
python:mainfrom
chgnrdv:trace-fix-lacking-newlines

Conversation

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

Copy link
Copy Markdown
Contributor

check if call to `linecache.getline` returns non-empty string
otherwise print only filename with lineno

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)

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Could you please add some tests?

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.

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

serhiy-storchaka merged commit 7c87ce7 into python:main 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.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2024
…ythonGH-103958)

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

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2024
…ythonGH-103958)

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

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>

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.

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

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.

bedevere-app Bot removed the needs backport to 3.11 only security fixes label May 9, 2024
serhiy-storchaka added the needs backport to 3.13 bugs and security fixes label 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!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2024
…ythonGH-103958)

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

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>

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.

bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label 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.

serhiy-storchaka pushed a commit that referenced this pull request May 9, 2024
…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 <52372310+chgnrdv@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this pull request May 9, 2024
…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 <52372310+chgnrdv@users.noreply.github.com>
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 9, 2024
…ythonGH-103958)

Print only filename with lineno if linecache.getline() returns an empty string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants


Back | FazBrowse Home | New Git URL