Mercurial > cpython-lru_cache-weakref
comparison Python/errors.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 | 9e3469c0ed75 |
| children | d0d0a69b5ca3 |
comparison
equal
deleted
inserted
replaced
| 2051:23dfca8aa73b | 2052:d7e91437f0a2 |
|---|---|
| 58 #include "allobjects.h" | 58 #include "allobjects.h" |
| 59 #include "traceback.h" | 59 #include "traceback.h" |
| 60 | 60 |
| 61 #include <errno.h> | 61 #include <errno.h> |
| 62 | 62 |
| 63 #ifndef NT | |
| 63 #ifdef macintosh | 64 #ifdef macintosh |
| 64 /* | 65 /* |
| 65 ** For the mac, there's a function macstrerror in macosmodule.c. We can't | 66 ** For the mac, there's a function macstrerror in macosmodule.c. We can't |
| 66 ** call it strerror(), though, since that is already defined (for Think C) | 67 ** call it strerror(), though, since that is already defined (for Think C) |
| 67 ** in ANSI | 68 ** in ANSI |
| 68 */ | 69 */ |
| 69 #define strerror macstrerror | 70 #define strerror macstrerror |
| 70 #include "macdefs.h" /* For CW to find EINTR */ | 71 #include "macdefs.h" /* For CW to find EINTR */ |
| 71 #endif /* macintosh */ | 72 #endif /* !macintosh */ |
| 72 | |
| 73 extern char *strerror PROTO((int)); | 73 extern char *strerror PROTO((int)); |
| 74 #endif /* !NT */ | |
| 74 | 75 |
| 75 /* Last exception stored by err_setval() */ | 76 /* Last exception stored by err_setval() */ |
| 76 | 77 |
| 77 static object *last_exception; | 78 static object *last_exception; |
| 78 static object *last_exc_val; | 79 static object *last_exc_val; |
| 79 | 80 |
| 80 void | 81 void |
| 82 err_restore(exception, value, traceback) | |
| 83 object *exception; | |
| 84 object *value; | |
| 85 object *traceback; | |
| 86 { | |
| 87 err_clear(); | |
| 88 | |
| 89 last_exception = exception; | |
| 90 last_exc_val = value; | |
| 91 (void) tb_store(traceback); | |
| 92 XDECREF(traceback); | |
| 93 } | |
| 94 | |
| 95 void | |
| 81 err_setval(exception, value) | 96 err_setval(exception, value) |
| 82 object *exception; | 97 object *exception; |
| 83 object *value; | 98 object *value; |
| 84 { | 99 { |
| 85 err_clear(); | |
| 86 | |
| 87 XINCREF(exception); | 100 XINCREF(exception); |
| 88 last_exception = exception; | |
| 89 | |
| 90 XINCREF(value); | 101 XINCREF(value); |
| 91 last_exc_val = value; | 102 err_restore(exception, value, (object *)NULL); |
| 92 } | 103 } |
| 93 | 104 |
| 94 void | 105 void |
| 95 err_set(exception) | 106 err_set(exception) |
| 96 object *exception; | 107 object *exception; |
| 114 { | 125 { |
| 115 return last_exception; | 126 return last_exception; |
| 116 } | 127 } |
| 117 | 128 |
| 118 void | 129 void |
| 119 err_get(p_exc, p_val) | 130 err_fetch(p_exc, p_val, p_tb) |
| 120 object **p_exc; | 131 object **p_exc; |
| 121 object **p_val; | 132 object **p_val; |
| 133 object **p_tb; | |
| 122 { | 134 { |
| 123 *p_exc = last_exception; | 135 *p_exc = last_exception; |
| 124 last_exception = NULL; | 136 last_exception = NULL; |
| 125 *p_val = last_exc_val; | 137 *p_val = last_exc_val; |
| 126 last_exc_val = NULL; | 138 last_exc_val = NULL; |
| 139 *p_tb = tb_fetch(); | |
| 127 } | 140 } |
| 128 | 141 |
| 129 void | 142 void |
| 130 err_clear() | 143 err_clear() |
| 131 { | 144 { |
