bpo-43933: Show frame.f_lineno as None, rather than -1, if there is no line number. (GH-25717)

This commit is contained in:
Mark Shannon 2021-04-29 19:28:50 +01:00 committed by GitHub
parent 2fd928c8c1
commit 088a15c49d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View file

@ -53,7 +53,13 @@ PyFrame_GetLineNumber(PyFrameObject *f)
static PyObject *
frame_getlineno(PyFrameObject *f, void *closure)
{
return PyLong_FromLong(PyFrame_GetLineNumber(f));
int lineno = PyFrame_GetLineNumber(f);
if (lineno < 0) {
Py_RETURN_NONE;
}
else {
return PyLong_FromLong(lineno);
}
}
static PyObject *