Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13836d9

Browse files
committed
add function name to traceback info
MPW fixes
1 parent d2002c7 commit 13836d9

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

Python/traceback.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***********************************************************
2-
Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
2+
Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
33
Amsterdam, The Netherlands.
44
55
All Rights Reserved
@@ -74,9 +74,9 @@ static typeobject Tracebacktype = {
7474
"traceback",
7575
sizeof(tracebackobject),
7676
0,
77-
tb_dealloc, /*tp_dealloc*/
77+
(destructor)tb_dealloc, /*tp_dealloc*/
7878
0, /*tp_print*/
79-
tb_getattr, /*tp_getattr*/
79+
(getattrfunc)tb_getattr, /*tp_getattr*/
8080
0, /*tp_setattr*/
8181
0, /*tp_compare*/
8282
0, /*tp_repr*/
@@ -150,14 +150,22 @@ tb_store(v)
150150
}
151151

152152
static void
153-
tb_displayline(f, filename, lineno)
153+
tb_displayline(f, filename, lineno, name)
154154
object *f;
155155
char *filename;
156156
int lineno;
157+
char *name;
157158
{
158159
FILE *xfp;
159160
char linebuf[1000];
160161
int i;
162+
#ifdef MPW
163+
/* This is needed by MPW's File and Line commands */
164+
#define FMT " File \"%.900s\"; line %d # in %s\n"
165+
#else
166+
/* This is needed by Emacs' compile command */
167+
#define FMT " File \"%.900s\", line %d, in %s\n"
168+
#endif
161169
xfp = fopen(filename, "r");
162170
if (xfp == NULL) {
163171
/* Search tail of filename in sys.path before giving up */
@@ -189,16 +197,7 @@ tb_displayline(f, filename, lineno)
189197
}
190198
}
191199
}
192-
sprintf(linebuf, " File \"%.900s\"%s line %d\n",
193-
filename,
194-
#ifdef applec /* MPW */
195-
/* This is needed by MPW's File and Line commands */
196-
";",
197-
#else
198-
/* This is needed by Emacs' compile command */
199-
",",
200-
#endif
201-
lineno);
200+
sprintf(linebuf, FMT, filename, lineno, name);
202201
writestring(linebuf, f);
203202
if (xfp == NULL)
204203
return;
@@ -234,7 +233,8 @@ tb_printinternal(tb, f, limit)
234233
if (depth <= limit)
235234
tb_displayline(f,
236235
getstringvalue(tb->tb_frame->f_code->co_filename),
237-
tb->tb_lineno);
236+
tb->tb_lineno,
237+
getstringvalue(tb->tb_frame->f_code->co_name));
238238
depth--;
239239
tb = tb->tb_next;
240240
}

0 commit comments

Comments
 (0)