Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 2062:d0d0a69b5ca3 legacy-trunk
Added 1995 to copyright message.
bltinmodule.c: fixed coerce() nightmare in ternary pow().
modsupport.c (initmodule2): pass METH_FREENAME flag to newmethodobject().
pythonrun.c: move flushline() into and around print_error().
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 04 Jan 1995 19:12:13 +0000 |
| parents | d7e91437f0a2 |
| children | b7be0382f9ee |
comparison
equal
deleted
inserted
replaced
| 2061:172ba04a5191 | 2062:d0d0a69b5ca3 |
|---|---|
| 1 /*********************************************************** | 1 /*********************************************************** |
| 2 Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum, | 2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 Amsterdam, The Netherlands. | 3 The Netherlands. |
| 4 | 4 |
| 5 All Rights Reserved | 5 All Rights Reserved |
| 6 | 6 |
| 7 Permission to use, copy, modify, and distribute this software and its | 7 Permission to use, copy, modify, and distribute this software and its |
| 8 documentation for any purpose and without fee is hereby granted, | 8 documentation for any purpose and without fee is hereby granted, |
| 176 m = add_module("__main__"); | 176 m = add_module("__main__"); |
| 177 if (m == NULL) | 177 if (m == NULL) |
| 178 return -1; | 178 return -1; |
| 179 d = getmoduledict(m); | 179 d = getmoduledict(m); |
| 180 v = run_node(n, filename, d, d); | 180 v = run_node(n, filename, d, d); |
| 181 flushline(); | |
| 182 if (v == NULL) { | 181 if (v == NULL) { |
| 183 print_error(); | 182 print_error(); |
| 184 return -1; | 183 return -1; |
| 185 } | 184 } |
| 186 DECREF(v); | 185 DECREF(v); |
| 186 flushline(); | |
| 187 return 0; | 187 return 0; |
| 188 } | 188 } |
| 189 | 189 |
| 190 int | 190 int |
| 191 run_script(fp, filename) | 191 run_script(fp, filename) |
| 209 } | 209 } |
| 210 v = run_pyc_file(fp, filename, d, d); | 210 v = run_pyc_file(fp, filename, d, d); |
| 211 } else { | 211 } else { |
| 212 v = run_file(fp, filename, file_input, d, d); | 212 v = run_file(fp, filename, file_input, d, d); |
| 213 } | 213 } |
| 214 flushline(); | |
| 215 if (v == NULL) { | 214 if (v == NULL) { |
| 216 print_error(); | 215 print_error(); |
| 217 return -1; | 216 return -1; |
| 218 } | 217 } |
| 219 DECREF(v); | 218 DECREF(v); |
| 219 flushline(); | |
| 220 return 0; | 220 return 0; |
| 221 } | 221 } |
| 222 | 222 |
| 223 int | 223 int |
| 224 run_command(command) | 224 run_command(command) |
| 228 m = add_module("__main__"); | 228 m = add_module("__main__"); |
| 229 if (m == NULL) | 229 if (m == NULL) |
| 230 return -1; | 230 return -1; |
| 231 d = getmoduledict(m); | 231 d = getmoduledict(m); |
| 232 v = run_string(command, file_input, d, d); | 232 v = run_string(command, file_input, d, d); |
| 233 flushline(); | |
| 234 if (v == NULL) { | 233 if (v == NULL) { |
| 235 print_error(); | 234 print_error(); |
| 236 return -1; | 235 return -1; |
| 237 } | 236 } |
| 238 DECREF(v); | 237 DECREF(v); |
| 238 flushline(); | |
| 239 return 0; | 239 return 0; |
| 240 } | 240 } |
| 241 | 241 |
| 242 void | 242 void |
| 243 print_error() | 243 print_error() |
| 244 { | 244 { |
| 245 object *exception, *v, *tb, *f; | 245 object *exception, *v, *tb, *f; |
| 246 err_fetch(&exception, &v, &tb); | 246 err_fetch(&exception, &v, &tb); |
| 247 flushline(); | |
| 247 if (exception == NULL) | 248 if (exception == NULL) |
| 248 fatal("print_error called but no exception"); | 249 fatal("print_error called but no exception"); |
| 249 if (exception == SystemExit) { | 250 if (exception == SystemExit) { |
| 250 if (v == NULL || v == None) | 251 if (v == NULL || v == None) |
| 251 goaway(0); | 252 goaway(0); |
