Skip to content

bpo-43950: ensure source_line is present when specializing the traceback#27313

Merged
pablogsal merged 3 commits intopython:mainfrom
colnotab:ensure-source-line-is-displayed
Jul 24, 2021
Merged

bpo-43950: ensure source_line is present when specializing the traceback#27313
pablogsal merged 3 commits intopython:mainfrom
colnotab:ensure-source-line-is-displayed

Conversation

@isidentical
Copy link
Member

@isidentical isidentical commented Jul 23, 2021

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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants