summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-09-25 21:59:05 (GMT)
committerGuido van Rossum <guido@python.org>1992-09-25 21:59:05 (GMT)
commit3165fe6a56c07f4f85f4ea54b69f5b1f243e2463 (patch)
treee4721159db6fc00c4267e03c035b58b73c854fd5 /Python/pythonrun.c
parent3a40ae4ef3b3dd7f2967a63acceabb0d0ae251d7 (diff)
downloadcpython-3165fe6a56c07f4f85f4ea54b69f5b1f243e2463.zip
cpython-3165fe6a56c07f4f85f4ea54b69f5b1f243e2463.tar.gz
cpython-3165fe6a56c07f4f85f4ea54b69f5b1f243e2463.tar.bz2
Modified most (but not yet all) I/O to always go through sys.stdout or
sys.stderr or sys.stdin, and to work with any object as long as it has a write() (respectively readline()) methods. Some functions that took a FILE* argument now take an object* argument.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 35b1815..90a4294 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -214,7 +214,7 @@ run_command(command)
void
print_error()
{
- object *exception, *v;
+ object *exception, *v, *f;
err_get(&exception, &v);
if (exception == SystemExit) {
if (v == NULL || v == None)
@@ -222,6 +222,7 @@ print_error()
if (is_intobject(v))
goaway((int)getintvalue(v));
else {
+ /* OK to use real stderr here */
printobject(v, stderr, PRINT_RAW);
fprintf(stderr, "\n");
goaway(1);
@@ -229,17 +230,22 @@ print_error()
}
sysset("last_type", exception);
sysset("last_value", v);
- if (printobject(exception, stderr, PRINT_RAW) != 0)
- err_clear();
- if (v != NULL && v != None) {
- fprintf(stderr, ": ");
- if (printobject(v, stderr, PRINT_RAW) != 0)
+ f = sysget("stderr");
+ if (f == NULL)
+ fprintf(stderr, "lost sys.stderr\n");
+ else {
+ if (writeobject(exception, f, PRINT_RAW) != 0)
err_clear();
+ if (v != NULL && v != None) {
+ writestring(": ", f);
+ if (writeobject(v, f, PRINT_RAW) != 0)
+ err_clear();
+ }
+ writestring("\n", f);
+ printtraceback(f);
}
- fprintf(stderr, "\n");
XDECREF(exception);
XDECREF(v);
- printtraceback(stderr);
}
object *