@@ -581,6 +581,7 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
581581 err = PyErr_CheckSignals ();
582582 }
583583 }
584+ Py_DECREF (code );
584585 tb = tb -> tb_next ;
585586 }
586587 if (err == 0 && cnt > TB_RECURSIVE_CUTOFF ) {
@@ -752,12 +753,9 @@ _Py_DumpASCII(int fd, PyObject *text)
752753static void
753754dump_frame (int fd , PyFrameObject * frame )
754755{
755- PyCodeObject * code ;
756- int lineno ;
757-
758- code = PyFrame_GetCode (frame );
756+ PyCodeObject * code = PyFrame_GetCode (frame );
759757 PUTS (fd , " File " );
760- if (code != NULL && code -> co_filename != NULL
758+ if (code -> co_filename != NULL
761759 && PyUnicode_Check (code -> co_filename ))
762760 {
763761 PUTS (fd , "\"" );
@@ -768,7 +766,7 @@ dump_frame(int fd, PyFrameObject *frame)
768766 }
769767
770768 /* PyFrame_GetLineNumber() was introduced in Python 2.7.0 and 3.2.0 */
771- lineno = PyCode_Addr2Line (code , frame -> f_lasti );
769+ int lineno = PyCode_Addr2Line (code , frame -> f_lasti );
772770 PUTS (fd , ", line " );
773771 if (lineno >= 0 ) {
774772 _Py_DumpDecimal (fd , (unsigned long )lineno );
@@ -778,7 +776,7 @@ dump_frame(int fd, PyFrameObject *frame)
778776 }
779777 PUTS (fd , " in " );
780778
781- if (code != NULL && code -> co_name != NULL
779+ if (code -> co_name != NULL
782780 && PyUnicode_Check (code -> co_name )) {
783781 _Py_DumpASCII (fd , code -> co_name );
784782 }
@@ -787,6 +785,7 @@ dump_frame(int fd, PyFrameObject *frame)
787785 }
788786
789787 PUTS (fd , "\n" );
788+ Py_DECREF (code );
790789}
791790
792791static void
0 commit comments