cpython: fea3c6e9a38e (original) (raw)
Mercurial > cpython
changeset 100549:fea3c6e9a38e 3.5
_tracemalloc: store lineno as unsigned int Issue #26564. Cleanup the code, lineno is never negative. [#26564]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Tue, 15 Mar 2016 21:57:02 +0100 |
parents | c298c6d8b324 |
children | 5eb223e1638c e95e9701b472 |
files | Modules/_tracemalloc.c |
diffstat | 1 files changed, 7 insertions(+), 17 deletions(-)[+] [-] Modules/_tracemalloc.c 24 |
line wrap: on
line diff
--- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -66,7 +66,7 @@ typedef struct #endif { PyObject *filename;
} frame_t; typedef struct { @@ -266,12 +266,13 @@ tracemalloc_get_frame(PyFrameObject *pyf PyCodeObject *code; PyObject *filename; _Py_hashtable_entry_t *entry;
frame->filename = unknown_filename;
- frame->lineno = PyFrame_GetLineNumber(pyframe);
- assert(frame->lineno >= 0);
- if (frame->lineno < 0)
frame->lineno = 0;[](#l1.22)
- lineno = PyFrame_GetLineNumber(pyframe);
- if (lineno < 0)
lineno = 0;[](#l1.25)
- frame->lineno = (unsigned int)lineno;
code = pyframe->f_code; if (code == NULL) { @@ -375,7 +376,6 @@ traceback_get_frames(traceback_t *traceb for (pyframe = tstate->frame; pyframe != NULL; pyframe = pyframe->f_back) { tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]); assert(traceback->frames[traceback->nframe].filename != NULL);
assert(traceback->frames[traceback->nframe].lineno >= 0);[](#l1.34) traceback->nframe++;[](#l1.35) if (traceback->nframe == tracemalloc_config.max_nframe)[](#l1.36) break;[](#l1.37)
@@ -943,15 +943,6 @@ tracemalloc_stop(void) tracemalloc_traceback = NULL; } -static PyObject* -lineno_as_obj(int lineno) -{
-} - PyDoc_STRVAR(tracemalloc_is_tracing_doc, "is_tracing()->bool\n" "\n" @@ -996,8 +987,7 @@ frame_to_pyobject(frame_t *frame) Py_INCREF(frame->filename); PyTuple_SET_ITEM(frame_obj, 0, frame->filename);