comparison Python/pythonrun.c @ 2052:d7e91437f0a2 legacy-trunk

Lots of changes, most minor (fatal() instead of abort(), use of err_fetch/err_restore and so on). But... NOTE: import.c has been rewritten and all the DL stuff is now in the new file importdl.c.
author Guido van Rossum <guido@python.org>
date Mon, 02 Jan 1995 19:04:15 +0000
parents eee3d715f0cf
children d0d0a69b5ca3
comparison
equal deleted inserted replaced
2051:23dfca8aa73b 2052:d7e91437f0a2
240 } 240 }
241 241
242 void 242 void
243 print_error() 243 print_error()
244 { 244 {
245 object *exception, *v, *f; 245 object *exception, *v, *tb, *f;
246 err_get(&exception, &v); 246 err_fetch(&exception, &v, &tb);
247 if (exception == NULL) { 247 if (exception == NULL)
248 fprintf(stderr, "print_error called but no exception\n"); 248 fatal("print_error called but no exception");
249 abort();
250 }
251 if (exception == SystemExit) { 249 if (exception == SystemExit) {
252 if (v == NULL || v == None) 250 if (v == NULL || v == None)
253 goaway(0); 251 goaway(0);
254 if (is_intobject(v)) 252 if (is_intobject(v))
255 goaway((int)getintvalue(v)); 253 goaway((int)getintvalue(v));
260 goaway(1); 258 goaway(1);
261 } 259 }
262 } 260 }
263 sysset("last_type", exception); 261 sysset("last_type", exception);
264 sysset("last_value", v); 262 sysset("last_value", v);
263 sysset("last_traceback", tb);
265 f = sysget("stderr"); 264 f = sysget("stderr");
266 if (f == NULL) 265 if (f == NULL)
267 fprintf(stderr, "lost sys.stderr\n"); 266 fprintf(stderr, "lost sys.stderr\n");
268 else { 267 else {
269 printtraceback(f); 268 tb_print(tb, f);
270 if (exception == SyntaxError) { 269 if (exception == SyntaxError) {
271 object *message; 270 object *message;
272 char *filename, *text; 271 char *filename, *text;
273 int lineno, offset; 272 int lineno, offset;
274 if (!getargs(v, "(O(ziiz))", &message, 273 if (!getargs(v, "(O(ziiz))", &message,
329 } 328 }
330 writestring("\n", f); 329 writestring("\n", f);
331 } 330 }
332 XDECREF(exception); 331 XDECREF(exception);
333 XDECREF(v); 332 XDECREF(v);
333 XDECREF(tb);
334 } 334 }
335 335
336 object * 336 object *
337 run_string(str, start, globals, locals) 337 run_string(str, start, globals, locals)
338 char *str; 338 char *str;
419 char *str; 419 char *str;
420 char *filename; 420 char *filename;
421 int start; 421 int start;
422 { 422 {
423 node *n; 423 node *n;
424 int err;
425 codeobject *co; 424 codeobject *co;
426 n = parse_string(str, start); 425 n = parse_string(str, start);
427 if (n == NULL) 426 if (n == NULL)
428 return NULL; 427 return NULL;
429 co = compile(n, filename); 428 co = compile(n, filename);