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

Skip to content

Commit 262e124

Browse files
committed
print class name for exceptions that are classes
1 parent 9e89f0a commit 262e124

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Python/pythonrun.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ static object *run_err_node PROTO((node *n, char *filename,
6262
object *globals, object *locals));
6363
static object *run_node PROTO((node *n, char *filename,
6464
object *globals, object *locals));
65+
static object *run_pyc_file PROTO((FILE *fp, char *filename,
66+
object *globals, object *locals));
6567
static void err_input PROTO((perrdetail *));
6668
static void initsigs PROTO((void));
6769

@@ -348,8 +350,18 @@ print_error()
348350
v = message;
349351
}
350352
}
351-
if (writeobject(exception, f, PRINT_RAW) != 0)
352-
err_clear();
353+
if (is_classobject(exception)) {
354+
object* className = ((classobject*)exception)->cl_name;
355+
if (className == NULL)
356+
writestring("<unknown>", f);
357+
else {
358+
if (writeobject(className, f, PRINT_RAW) != 0)
359+
err_clear();
360+
}
361+
} else {
362+
if (writeobject(exception, f, PRINT_RAW) != 0)
363+
err_clear();
364+
}
353365
if (v != NULL && v != None) {
354366
writestring(": ", f);
355367
if (writeobject(v, f, PRINT_RAW) != 0)

0 commit comments

Comments
 (0)