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

Skip to content

Commit d783a46

Browse files
committed
printobject now returns an error code
1 parent 9093361 commit d783a46

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

Include/object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ typedef struct _typeobject {
162162
/* Methods to implement standard operations */
163163

164164
void (*tp_dealloc) FPROTO((object *));
165-
void (*tp_print) FPROTO((object *, FILE *, int));
165+
int (*tp_print) FPROTO((object *, FILE *, int));
166166
object *(*tp_getattr) FPROTO((object *, char *));
167167
int (*tp_setattr) FPROTO((object *, char *, object *));
168168
int (*tp_compare) FPROTO((object *, object *));
@@ -180,7 +180,7 @@ extern typeobject Typetype; /* The type of type objects */
180180
#define is_typeobject(op) ((op)->ob_type == &Typetype)
181181

182182
/* Generic operations on objects */
183-
extern void printobject PROTO((object *, FILE *, int));
183+
extern int printobject PROTO((object *, FILE *, int));
184184
extern object * reprobject PROTO((object *));
185185
extern int cmpobject PROTO((object *, object *));
186186
extern object *getattr PROTO((object *, char *));

Modules/stdwinmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,13 +1286,14 @@ window_dealloc(wp)
12861286
free((char *)wp);
12871287
}
12881288

1289-
static void
1289+
static int
12901290
window_print(wp, fp, flags)
12911291
windowobject *wp;
12921292
FILE *fp;
12931293
int flags;
12941294
{
12951295
fprintf(fp, "<window titled '%s'>", getstringvalue(wp->w_title));
1296+
return 0;
12961297
}
12971298

12981299
static object *

Python/pythonmain.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,12 @@ print_error()
289289
object *exception, *v;
290290
err_get(&exception, &v);
291291
fprintf(stderr, "Unhandled exception: ");
292-
printobject(exception, stderr, PRINT_RAW);
292+
if (printobject(exception, stderr, PRINT_RAW) != 0)
293+
err_clear();
293294
if (v != NULL && v != None) {
294295
fprintf(stderr, ": ");
295-
printobject(v, stderr, PRINT_RAW);
296+
if (printobject(v, stderr, PRINT_RAW) != 0)
297+
err_clear();
296298
}
297299
fprintf(stderr, "\n");
298300
XDECREF(exception);

Python/traceback.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,14 @@ tb_printinternal(tb, fp)
186186
FILE *fp;
187187
{
188188
while (tb != NULL) {
189-
if (intrcheck()) {
190-
fprintf(fp, "[interrupted]\n");
189+
if (intrcheck())
191190
break;
192-
}
193191
fprintf(fp, " File \"");
194-
printobject(tb->tb_frame->f_code->co_filename, fp, PRINT_RAW);
192+
if (printobject(tb->tb_frame->f_code->co_filename,
193+
fp, PRINT_RAW) != 0) {
194+
err_clear();
195+
break;
196+
}
195197
fprintf(fp, "\", line %d\n", tb->tb_lineno);
196198
tb_displayline(fp,
197199
getstringvalue(tb->tb_frame->f_code->co_filename),

0 commit comments

Comments
 (0)