summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-04-29 18:28:50 (GMT)
committerGitHub <noreply@github.com>2021-04-29 18:28:50 (GMT)
commit088a15c49d99ecb4c3bef93f8f40dd513c6cae3b (patch)
tree547dc91a32ba1c1885bc9b8cc1ae7f66e1722f5e /Objects
parent2fd928c8c1328424130cb9c51fc02ad5f9a66328 (diff)
downloadcpython-088a15c49d99ecb4c3bef93f8f40dd513c6cae3b.zip
cpython-088a15c49d99ecb4c3bef93f8f40dd513c6cae3b.tar.gz
cpython-088a15c49d99ecb4c3bef93f8f40dd513c6cae3b.tar.bz2
bpo-43933: Show frame.f_lineno as None, rather than -1, if there is no line number. (GH-25717)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/frameobject.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index b0487c2..5920ed8 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -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 *