@@ -66,7 +66,7 @@ _declspec(align(4))
6666#endif
6767{
6868 PyObject * filename ;
69- int lineno ;
69+ unsigned int lineno ;
7070} frame_t ;
7171
7272typedef struct {
@@ -266,12 +266,13 @@ tracemalloc_get_frame(PyFrameObject *pyframe, frame_t *frame)
266266 PyCodeObject * code ;
267267 PyObject * filename ;
268268 _Py_hashtable_entry_t * entry ;
269+ int lineno ;
269270
270271 frame -> filename = unknown_filename ;
271- frame -> lineno = PyFrame_GetLineNumber (pyframe );
272- assert ( frame -> lineno >= 0 );
273- if ( frame -> lineno < 0 )
274- frame -> lineno = 0 ;
272+ lineno = PyFrame_GetLineNumber (pyframe );
273+ if ( lineno < 0 )
274+ lineno = 0 ;
275+ frame -> lineno = ( unsigned int ) lineno ;
275276
276277 code = pyframe -> f_code ;
277278 if (code == NULL ) {
@@ -375,7 +376,6 @@ traceback_get_frames(traceback_t *traceback)
375376 for (pyframe = tstate -> frame ; pyframe != NULL ; pyframe = pyframe -> f_back ) {
376377 tracemalloc_get_frame (pyframe , & traceback -> frames [traceback -> nframe ]);
377378 assert (traceback -> frames [traceback -> nframe ].filename != NULL );
378- assert (traceback -> frames [traceback -> nframe ].lineno >= 0 );
379379 traceback -> nframe ++ ;
380380 if (traceback -> nframe == tracemalloc_config .max_nframe )
381381 break ;
@@ -943,15 +943,6 @@ tracemalloc_stop(void)
943943 tracemalloc_traceback = NULL ;
944944}
945945
946- static PyObject *
947- lineno_as_obj (int lineno )
948- {
949- if (lineno >= 0 )
950- return PyLong_FromLong (lineno );
951- else
952- Py_RETURN_NONE ;
953- }
954-
955946PyDoc_STRVAR (tracemalloc_is_tracing_doc ,
956947 "is_tracing()->bool\n"
957948 "\n"
@@ -996,8 +987,7 @@ frame_to_pyobject(frame_t *frame)
996987 Py_INCREF (frame -> filename );
997988 PyTuple_SET_ITEM (frame_obj , 0 , frame -> filename );
998989
999- assert (frame -> lineno >= 0 );
1000- lineno_obj = lineno_as_obj (frame -> lineno );
990+ lineno_obj = PyLong_FromUnsignedLong (frame -> lineno );
1001991 if (lineno_obj == NULL ) {
1002992 Py_DECREF (frame_obj );
1003993 return NULL ;
0 commit comments