@@ -2667,7 +2667,7 @@ void PyLib_RedirectStdOut(void)
2667
2667
2668
2668
2669
2669
static const int PYLIB_RECURSIVE_CUTOFF = 3 ;
2670
- #define PyLib_TraceBack_LIMIT 1024
2670
+ #define PyLib_TraceBack_LIMIT 1024
2671
2671
2672
2672
static PyObject * format_displayline (PyObject * filename , int lineno , PyObject * name )
2673
2673
{
@@ -2730,6 +2730,10 @@ static int append_to_java_message(PyObject * pyObjUtf8, char **buf, int *bufLen
2730
2730
return 0 ;
2731
2731
}
2732
2732
2733
+ static int get_traceback_lineno (PyTracebackObject * tb ) {
2734
+ return (int )PyLong_AsLong (PyObject_GetAttrString ((PyObject * )tb , "tb_lineno" ));
2735
+ }
2736
+
2733
2737
static int format_python_traceback (PyTracebackObject * tb , char * * buf , int * bufLen )
2734
2738
{
2735
2739
int err = 0 ;
@@ -2754,7 +2758,7 @@ static int format_python_traceback(PyTracebackObject *tb, char **buf, int *bufLe
2754
2758
PyCodeObject * co = PyFrame_GetCode (tb -> tb_frame );
2755
2759
if (last_file == NULL ||
2756
2760
co -> co_filename != last_file ||
2757
- last_line == -1 || tb -> tb_lineno != last_line ||
2761
+ last_line == -1 || get_traceback_lineno ( tb ) != last_line ||
2758
2762
last_name == NULL || co -> co_name != last_name ) {
2759
2763
if (cnt > PYLIB_RECURSIVE_CUTOFF ) {
2760
2764
pyObjUtf8 = format_line_repeated (cnt );
@@ -2765,15 +2769,15 @@ static int format_python_traceback(PyTracebackObject *tb, char **buf, int *bufLe
2765
2769
}
2766
2770
}
2767
2771
last_file = co -> co_filename ;
2768
- last_line = tb -> tb_lineno ;
2772
+ last_line = get_traceback_lineno ( tb ) ;
2769
2773
last_name = co -> co_name ;
2770
2774
cnt = 0 ;
2771
2775
}
2772
2776
cnt ++ ;
2773
2777
if (err == 0 && cnt <= PYLIB_RECURSIVE_CUTOFF ) {
2774
2778
pyObjUtf8 = format_displayline (
2775
2779
co -> co_filename ,
2776
- tb -> tb_lineno ,
2780
+ get_traceback_lineno ( tb ) ,
2777
2781
co -> co_name );
2778
2782
err = append_to_java_message (pyObjUtf8 , buf , bufLen );
2779
2783
if (err != 0 ) {
0 commit comments