Skip to content

Commit

Permalink
printobject now returns an error code
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Jun 7, 1991
1 parent 9093361 commit d783a46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ typedef struct _typeobject {
/* Methods to implement standard operations */

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

/* Generic operations on objects */
extern void printobject PROTO((object *, FILE *, int));
extern int printobject PROTO((object *, FILE *, int));
extern object * reprobject PROTO((object *));
extern int cmpobject PROTO((object *, object *));
extern object *getattr PROTO((object *, char *));
Expand Down
3 changes: 2 additions & 1 deletion Modules/stdwinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,13 +1286,14 @@ window_dealloc(wp)
free((char *)wp);
}

static void
static int
window_print(wp, fp, flags)
windowobject *wp;
FILE *fp;
int flags;
{
fprintf(fp, "<window titled '%s'>", getstringvalue(wp->w_title));
return 0;
}

static object *
Expand Down
6 changes: 4 additions & 2 deletions Python/pythonmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,12 @@ print_error()
object *exception, *v;
err_get(&exception, &v);
fprintf(stderr, "Unhandled exception: ");
printobject(exception, stderr, PRINT_RAW);
if (printobject(exception, stderr, PRINT_RAW) != 0)
err_clear();
if (v != NULL && v != None) {
fprintf(stderr, ": ");
printobject(v, stderr, PRINT_RAW);
if (printobject(v, stderr, PRINT_RAW) != 0)
err_clear();
}
fprintf(stderr, "\n");
XDECREF(exception);
Expand Down
10 changes: 6 additions & 4 deletions Python/traceback.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@ tb_printinternal(tb, fp)
FILE *fp;
{
while (tb != NULL) {
if (intrcheck()) {
fprintf(fp, "[interrupted]\n");
if (intrcheck())
break;
}
fprintf(fp, " File \"");
printobject(tb->tb_frame->f_code->co_filename, fp, PRINT_RAW);
if (printobject(tb->tb_frame->f_code->co_filename,
fp, PRINT_RAW) != 0) {
err_clear();
break;
}
fprintf(fp, "\", line %d\n", tb->tb_lineno);
tb_displayline(fp,
getstringvalue(tb->tb_frame->f_code->co_filename),
Expand Down

0 comments on commit d783a46

Please sign in to comment.