Cython has moved to github.
pyrex
view Tests/7/Reference/traceback.c @ 86:da6e97bb7e6d
Multiple compilation fixed
| author | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| date | Sat May 24 15:50:12 2008 +1200 (4 years ago) |
| parents | 6c5f5271ebab |
| children | 3b20cb4923eb |
line source
1 /* Generated by Pyrex */
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #include "structmember.h"
6 #ifndef PY_LONG_LONG
7 #define PY_LONG_LONG LONG_LONG
8 #endif
9 #if PY_VERSION_HEX < 0x02050000
10 typedef int Py_ssize_t;
11 #define PY_SSIZE_T_MAX INT_MAX
12 #define PY_SSIZE_T_MIN INT_MIN
13 #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
14 #define PyInt_AsSsize_t(o) PyInt_AsLong(o)
15 #endif
16 #ifndef WIN32
17 #ifndef __stdcall
18 #define __stdcall
19 #endif
20 #ifndef __cdecl
21 #define __cdecl
22 #endif
23 #endif
24 #ifdef __cplusplus
25 #define __PYX_EXTERN_C extern "C"
26 #else
27 #define __PYX_EXTERN_C extern
28 #endif
29 #include <math.h>
32 typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
33 typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
35 static PyObject *__pyx_m;
36 static PyObject *__pyx_b;
37 static int __pyx_lineno;
38 static char *__pyx_filename;
39 static char **__pyx_f;
41 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
43 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
45 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
47 static void __Pyx_AddTraceback(char *funcname); /*proto*/
49 /* Declarations from traceback */
51 static int __pyx_f_9traceback_grail(void); /*proto*/
54 static __Pyx_StringTabEntry __pyx_string_tab[] = {
55 {&__pyx_n_spam, 1, __pyx_k1, sizeof(__pyx_k1)},
56 {0, 0, 0, 0}
57 };
59 /* Implementation of traceback */
61 static PyObject *__pyx_f_9traceback_spam(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
62 static PyObject *__pyx_f_9traceback_spam(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
63 PyObject *__pyx_r;
64 static char *__pyx_argnames[] = {0};
65 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
66 __Pyx_Raise(PyExc_Exception, 0, 0);
67 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
69 __pyx_r = Py_None; Py_INCREF(Py_None);
70 goto __pyx_L0;
71 __pyx_L1:;
72 __Pyx_AddTraceback("traceback.spam");
73 __pyx_r = 0;
74 __pyx_L0:;
75 return __pyx_r;
76 }
78 static int __pyx_f_9traceback_grail(void) {
79 int __pyx_r;
80 __Pyx_Raise(PyExc_Exception, 0, 0);
81 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
83 __pyx_r = 0;
84 goto __pyx_L0;
85 __pyx_L1:;
86 __Pyx_AddTraceback("traceback.grail");
87 __pyx_r = (-1);
88 __pyx_L0:;
89 return __pyx_r;
90 }
93 static PyObject *__pyx_f_9traceback_tomato(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
94 static PyObject *__pyx_f_9traceback_tomato(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
95 PyObject *__pyx_r;
96 PyObject *__pyx_1 = 0;
97 PyObject *__pyx_2 = 0;
98 int __pyx_3;
99 static char *__pyx_argnames[] = {0};
100 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
102 /* "/Local/Projects/D/Pyrex/Source/Tests/7/traceback.pyx":8 */
103 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_spam); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
104 __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
105 Py_DECREF(__pyx_1); __pyx_1 = 0;
106 Py_DECREF(__pyx_2); __pyx_2 = 0;
108 /* "/Local/Projects/D/Pyrex/Source/Tests/7/traceback.pyx":9 */
109 __pyx_3 = __pyx_f_9traceback_grail(); if (__pyx_3 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
111 __pyx_r = Py_None; Py_INCREF(Py_None);
112 goto __pyx_L0;
113 __pyx_L1:;
114 Py_XDECREF(__pyx_1);
115 Py_XDECREF(__pyx_2);
116 __Pyx_AddTraceback("traceback.tomato");
117 __pyx_r = 0;
118 __pyx_L0:;
119 return __pyx_r;
120 }
123 static struct PyMethodDef __pyx_methods[] = {
124 {"spam", (PyCFunction)__pyx_f_9traceback_spam, METH_VARARGS|METH_KEYWORDS, 0},
125 {"tomato", (PyCFunction)__pyx_f_9traceback_tomato, METH_VARARGS|METH_KEYWORDS, 0},
126 {0, 0, 0, 0}
127 };
129 static void __pyx_init_filenames(void); /*proto*/
131 PyMODINIT_FUNC inittraceback(void); /*proto*/
132 PyMODINIT_FUNC inittraceback(void) {
133 __pyx_init_filenames();
134 __pyx_m = Py_InitModule4("traceback", __pyx_methods, 0, 0, PYTHON_API_VERSION);
135 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
136 Py_INCREF(__pyx_m);
137 __pyx_b = PyImport_AddModule("__builtin__");
138 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
139 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
140 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
142 /* "/Local/Projects/D/Pyrex/Source/Tests/7/traceback.pyx":7 */
143 return;
144 __pyx_L1:;
145 __Pyx_AddTraceback("traceback");
146 }
148 static char *__pyx_filenames[] = {
149 "traceback.pyx",
150 };
152 /* Runtime support code */
154 static void __pyx_init_filenames(void) {
155 __pyx_f = __pyx_filenames;
156 }
158 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
159 Py_XINCREF(type);
160 Py_XINCREF(value);
161 Py_XINCREF(tb);
162 /* First, check the traceback argument, replacing None with NULL. */
163 if (tb == Py_None) {
164 Py_DECREF(tb);
165 tb = 0;
166 }
167 else if (tb != NULL && !PyTraceBack_Check(tb)) {
168 PyErr_SetString(PyExc_TypeError,
169 "raise: arg 3 must be a traceback or None");
170 goto raise_error;
171 }
172 /* Next, replace a missing value with None */
173 if (value == NULL) {
174 value = Py_None;
175 Py_INCREF(value);
176 }
177 #if PY_VERSION_HEX < 0x02050000
178 if (!PyClass_Check(type))
179 #else
180 if (!PyType_Check(type))
181 #endif
182 {
183 /* Raising an instance. The value should be a dummy. */
184 if (value != Py_None) {
185 PyErr_SetString(PyExc_TypeError,
186 "instance exception may not have a separate value");
187 goto raise_error;
188 }
189 /* Normalize to raise <class>, <instance> */
190 Py_DECREF(value);
191 value = type;
192 #if PY_VERSION_HEX < 0x02050000
193 if (PyInstance_Check(type)) {
194 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
195 Py_INCREF(type);
196 }
197 else {
198 PyErr_SetString(PyExc_TypeError,
199 "raise: exception must be an old-style class or instance");
200 goto raise_error;
201 }
202 #else
203 type = (PyObject*) type->ob_type;
204 Py_INCREF(type);
205 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
206 PyErr_SetString(PyExc_TypeError,
207 "raise: exception class must be a subclass of BaseException");
208 goto raise_error;
209 }
210 #endif
211 }
212 PyErr_Restore(type, value, tb);
213 return;
214 raise_error:
215 Py_XDECREF(value);
216 Py_XDECREF(type);
217 Py_XDECREF(tb);
218 return;
219 }
221 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
222 PyObject *result;
223 result = PyObject_GetAttr(dict, name);
224 if (!result)
225 PyErr_SetObject(PyExc_NameError, name);
226 return result;
227 }
229 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
230 while (t->p) {
231 *t->p = PyString_InternFromString(t->s);
232 if (!*t->p)
233 return -1;
234 ++t;
235 }
236 return 0;
237 }
239 #include "compile.h"
240 #include "frameobject.h"
241 #include "traceback.h"
243 static void __Pyx_AddTraceback(char *funcname) {
244 PyObject *py_srcfile = 0;
245 PyObject *py_funcname = 0;
246 PyObject *py_globals = 0;
247 PyObject *empty_tuple = 0;
248 PyObject *empty_string = 0;
249 PyCodeObject *py_code = 0;
250 PyFrameObject *py_frame = 0;
252 py_srcfile = PyString_FromString(__pyx_filename);
253 if (!py_srcfile) goto bad;
254 py_funcname = PyString_FromString(funcname);
255 if (!py_funcname) goto bad;
256 py_globals = PyModule_GetDict(__pyx_m);
257 if (!py_globals) goto bad;
258 empty_tuple = PyTuple_New(0);
259 if (!empty_tuple) goto bad;
260 empty_string = PyString_FromString("");
261 if (!empty_string) goto bad;
262 py_code = PyCode_New(
263 0, /*int argcount,*/
264 0, /*int nlocals,*/
265 0, /*int stacksize,*/
266 0, /*int flags,*/
267 empty_string, /*PyObject *code,*/
268 empty_tuple, /*PyObject *consts,*/
269 empty_tuple, /*PyObject *names,*/
270 empty_tuple, /*PyObject *varnames,*/
271 empty_tuple, /*PyObject *freevars,*/
272 empty_tuple, /*PyObject *cellvars,*/
273 py_srcfile, /*PyObject *filename,*/
274 py_funcname, /*PyObject *name,*/
275 __pyx_lineno, /*int firstlineno,*/
276 empty_string /*PyObject *lnotab*/
277 );
278 if (!py_code) goto bad;
279 py_frame = PyFrame_New(
280 PyThreadState_Get(), /*PyThreadState *tstate,*/
281 py_code, /*PyCodeObject *code,*/
282 py_globals, /*PyObject *globals,*/
283 0 /*PyObject *locals*/
284 );
285 if (!py_frame) goto bad;
286 py_frame->f_lineno = __pyx_lineno;
287 PyTraceBack_Here(py_frame);
288 bad:
289 Py_XDECREF(py_srcfile);
290 Py_XDECREF(py_funcname);
291 Py_XDECREF(empty_tuple);
292 Py_XDECREF(empty_string);
293 Py_XDECREF(py_code);
294 Py_XDECREF(py_frame);
295 }
