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 — bpo-43950: ensure source_line is present when specializing the traceback by isidentical · Pull Request #27313 · python/cpython

Conversation

@isidentical

@isidentical isidentical commented Jul 23, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

There seems to be different cases where the _PyDisplay_Line() function returns 0 without displaying the actual line but also without having any errors raised.

cpython/Python/traceback.c

Lines 414 to 420 in 4512848

/* use the right encoding to decode the file as unicode */
fd = PyObject_AsFileDescriptor(binary);
if (fd < 0) {
Py_DECREF(io);
Py_DECREF(binary);
return 0;
}

cpython/Python/traceback.c

Lines 436 to 446 in 4512848

if (fob == NULL) {
PyErr_Clear();
res = _PyObject_CallMethodIdNoArgs(binary, &PyId_close);
Py_DECREF(binary);
if (res)
Py_DECREF(res);
else
PyErr_Clear();
return 0;
}

This patch ensures that the line is retrieved and displayed.

https://bugs.python.org/issue43950

Sorry, something went wrong.

Uh oh!

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

All reactions
@isidentical
bpo-43950: ensure source_line is present when specializing the traceback
ff5ecbe
@bedevere-bot bedevere-bot added the awaiting core review label Jul 23, 2021
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jul 23, 2021
@isidentical isidentical added the skip news label Jul 23, 2021
@sweeneyde

sweeneyde commented Jul 23, 2021

Copy link
Copy Markdown
Member

Would it be better to fix _Py_DisplaySourceLine() instead?

All reactions

Sorry, something went wrong.

Uh oh!

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

@isidentical

isidentical commented Jul 23, 2021 via email

Copy link
Copy Markdown
Member Author
I am not sure how would the fix look beside introducing a new return code for cases that did not result with printing the line but also without an error which seems more complicated.
…
On Fri, Jul 23, 2021, 10:45 PM Dennis Sweeney ***@***.***> wrote: Would it be better to fix _Py_DisplaySourceLine() instead? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#27313 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ALJKHQPWWFKTA45LSTO5FS3TZHBGFANCNFSM5A4RI23Q> .
All reactions

Sorry, something went wrong.

Uh oh!

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

sweeneyde
sweeneyde approved these changes Jul 23, 2021
View reviewed changes
@pablogsal

pablogsal commented Jul 23, 2021

Copy link
Copy Markdown
Member

Can we add a regression test for this? (Like the one on the BPO issue?)

All reactions

Sorry, something went wrong.

Uh oh!

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

isidentical added 2 commits July 23, 2021 23:18
@isidentical
add a regression test
24bab74
@isidentical
use a lower value
8db4e0c
@isidentical isidentical added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 23, 2021
@bedevere-bot

bedevere-bot commented Jul 23, 2021

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @isidentical for commit 8db4e0c 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 23, 2021
@isidentical

isidentical commented Jul 24, 2021

Copy link
Copy Markdown
Member Author

It seems like refleaks bots also fail on the main too, so that can be ignored.

All reactions

Sorry, something went wrong.

Uh oh!

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

@isidentical
isidentical requested review from ammaraskar and pablogsal July 24, 2021 09:42
pablogsal
pablogsal approved these changes Jul 24, 2021
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jul 24, 2021
@pablogsal
pablogsal merged commit c836231 into python:main Jul 24, 2021
@bedevere-bot bedevere-bot removed the awaiting merge label Jul 24, 2021
@sthagen sthagen mentioned this pull request Jul 24, 2021
bpo-43950: ensure source_line is present when specialising the traceb… sthagen/python-cpython#561
Merged
@pablogsal pablogsal mentioned this pull request Apr 13, 2022
Include column offsets for bytecode instructions #88116
Closed
@serhiy-storchaka serhiy-storchaka mentioned this pull request Jun 9, 2026
gh-80384: Check that callback is callable at weak reference creation #151145
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pablogsal pablogsal pablogsal approved these changes
@sweeneyde sweeneyde sweeneyde approved these changes
@ammaraskar ammaraskar Awaiting requested review from ammaraskar

Uh oh!

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

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

5 participants

@isidentical @sweeneyde @pablogsal @bedevere-bot @the-knights-who-say-ni
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.