Cython has moved to github.
pyrex
view Tests/7/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 | 12072e0e4fd5 |
| children | 94d46b3c5354 |
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; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
34 static PyObject *__pyx_m;
35 static PyObject *__pyx_b;
36 static int __pyx_lineno;
37 static char *__pyx_filename;
38 static char **__pyx_f;
40 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
42 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
44 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
46 static void __Pyx_AddTraceback(char *funcname); /*proto*/
48 /* Declarations from traceback */
51 /* Declarations from implementation of traceback */
53 static int __pyx_f_9traceback_grail(void); /*proto*/
55 static char __pyx_k1[] = "spam";
57 static PyObject *__pyx_n_spam;
60 static __Pyx_StringTabEntry __pyx_string_tab[] = {
61 {&__pyx_n_spam, 1, __pyx_k1, sizeof(__pyx_k1)},
62 {0, 0, 0, 0}
63 };
67 /* Implementation of traceback */
69 static PyObject *__pyx_f_9traceback_spam(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
70 static PyObject *__pyx_f_9traceback_spam(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
71 PyObject *__pyx_r;
72 static char *__pyx_argnames[] = {0};
73 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
74 __Pyx_Raise(PyExc_Exception, 0, 0);
75 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
77 __pyx_r = Py_None; Py_INCREF(Py_None);
78 goto __pyx_L0;
79 __pyx_L1:;
80 __Pyx_AddTraceback("traceback.spam");
81 __pyx_r = 0;
82 __pyx_L0:;
83 return __pyx_r;
84 }
86 static int __pyx_f_9traceback_grail(void) {
87 int __pyx_r;
88 __Pyx_Raise(PyExc_Exception, 0, 0);
89 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
91 __pyx_r = 0;
92 goto __pyx_L0;
93 __pyx_L1:;
94 __Pyx_AddTraceback("traceback.grail");
95 __pyx_r = (-1);
96 __pyx_L0:;
97 return __pyx_r;
98 }
100 static PyObject *__pyx_f_9traceback_tomato(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
101 static PyObject *__pyx_f_9traceback_tomato(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
102 PyObject *__pyx_r;
103 PyObject *__pyx_1 = 0;
104 PyObject *__pyx_2 = 0;
105 int __pyx_3;
106 static char *__pyx_argnames[] = {0};
107 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
109 /* "/Local/Projects/D/Pyrex/Source/Tests/7/traceback.pyx":8 */
110 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_spam); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
111 __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
112 Py_DECREF(__pyx_1); __pyx_1 = 0;
113 Py_DECREF(__pyx_2); __pyx_2 = 0;
115 /* "/Local/Projects/D/Pyrex/Source/Tests/7/traceback.pyx":9 */
116 __pyx_3 = __pyx_f_9traceback_grail(); if (__pyx_3 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
118 __pyx_r = Py_None; Py_INCREF(Py_None);
119 goto __pyx_L0;
120 __pyx_L1:;
121 Py_XDECREF(__pyx_1);
122 Py_XDECREF(__pyx_2);
123 __Pyx_AddTraceback("traceback.tomato");
124 __pyx_r = 0;
125 __pyx_L0:;
126 return __pyx_r;
127 }
129 static struct PyMethodDef __pyx_methods[] = {
130 {"spam", (PyCFunction)__pyx_f_9traceback_spam, METH_VARARGS|METH_KEYWORDS, 0},
131 {"tomato", (PyCFunction)__pyx_f_9traceback_tomato, METH_VARARGS|METH_KEYWORDS, 0},
132 {0, 0, 0, 0}
133 };
135 static void __pyx_init_filenames(void); /*proto*/
137 PyMODINIT_FUNC inittraceback(void); /*proto*/
138 PyMODINIT_FUNC inittraceback(void) {
139 __pyx_init_filenames();
140 __pyx_m = Py_InitModule4("traceback", __pyx_methods, 0, 0, PYTHON_API_VERSION);
141 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
142 Py_INCREF(__pyx_m);
143 __pyx_b = PyImport_AddModule("__builtin__");
144 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
145 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
146 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
148 /* "/Local/Projects/D/Pyrex/Source/Tests/7/traceback.pyx":7 */
149 return;
150 __pyx_L1:;
151 __Pyx_AddTraceback("traceback");
152 }
154 static char *__pyx_filenames[] = {
155 "traceback.pyx",
156 };
158 /* Runtime support code */
160 static void __pyx_init_filenames(void) {
161 __pyx_f = __pyx_filenames;
162 }
164 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
165 Py_XINCREF(type);
166 Py_XINCREF(value);
167 Py_XINCREF(tb);
168 /* First, check the traceback argument, replacing None with NULL. */
169 if (tb == Py_None) {
170 Py_DECREF(tb);
171 tb = 0;
172 }
173 else if (tb != NULL && !PyTraceBack_Check(tb)) {
174 PyErr_SetString(PyExc_TypeError,
175 "raise: arg 3 must be a traceback or None");
176 goto raise_error;
177 }
178 /* Next, replace a missing value with None */
179 if (value == NULL) {
180 value = Py_None;
181 Py_INCREF(value);
182 }
183 #if PY_VERSION_HEX < 0x02050000
184 if (!PyClass_Check(type))
185 #else
186 if (!PyType_Check(type))
187 #endif
188 {
189 /* Raising an instance. The value should be a dummy. */
190 if (value != Py_None) {
191 PyErr_SetString(PyExc_TypeError,
192 "instance exception may not have a separate value");
193 goto raise_error;
194 }
195 /* Normalize to raise <class>, <instance> */
196 Py_DECREF(value);
197 value = type;
198 #if PY_VERSION_HEX < 0x02050000
199 if (PyInstance_Check(type)) {
200 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
201 Py_INCREF(type);
202 }
203 else {
204 PyErr_SetString(PyExc_TypeError,
205 "raise: exception must be an old-style class or instance");
206 goto raise_error;
207 }
208 #else
209 type = (PyObject*) type->ob_type;
210 Py_INCREF(type);
211 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
212 PyErr_SetString(PyExc_TypeError,
213 "raise: exception class must be a subclass of BaseException");
214 goto raise_error;
215 }
216 #endif
217 }
218 PyErr_Restore(type, value, tb);
219 return;
220 raise_error:
221 Py_XDECREF(value);
222 Py_XDECREF(type);
223 Py_XDECREF(tb);
224 return;
225 }
227 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
228 PyObject *result;
229 result = PyObject_GetAttr(dict, name);
230 if (!result)
231 PyErr_SetObject(PyExc_NameError, name);
232 return result;
233 }
235 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
236 while (t->p) {
237 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
238 if (!*t->p)
239 return -1;
240 if (t->i)
241 PyString_InternInPlace(t->p);
242 ++t;
243 }
244 return 0;
245 }
247 #include "compile.h"
248 #include "frameobject.h"
249 #include "traceback.h"
251 static void __Pyx_AddTraceback(char *funcname) {
252 PyObject *py_srcfile = 0;
253 PyObject *py_funcname = 0;
254 PyObject *py_globals = 0;
255 PyObject *empty_tuple = 0;
256 PyObject *empty_string = 0;
257 PyCodeObject *py_code = 0;
258 PyFrameObject *py_frame = 0;
260 py_srcfile = PyString_FromString(__pyx_filename);
261 if (!py_srcfile) goto bad;
262 py_funcname = PyString_FromString(funcname);
263 if (!py_funcname) goto bad;
264 py_globals = PyModule_GetDict(__pyx_m);
265 if (!py_globals) goto bad;
266 empty_tuple = PyTuple_New(0);
267 if (!empty_tuple) goto bad;
268 empty_string = PyString_FromString("");
269 if (!empty_string) goto bad;
270 py_code = PyCode_New(
271 0, /*int argcount,*/
272 0, /*int nlocals,*/
273 0, /*int stacksize,*/
274 0, /*int flags,*/
275 empty_string, /*PyObject *code,*/
276 empty_tuple, /*PyObject *consts,*/
277 empty_tuple, /*PyObject *names,*/
278 empty_tuple, /*PyObject *varnames,*/
279 empty_tuple, /*PyObject *freevars,*/
280 empty_tuple, /*PyObject *cellvars,*/
281 py_srcfile, /*PyObject *filename,*/
282 py_funcname, /*PyObject *name,*/
283 __pyx_lineno, /*int firstlineno,*/
284 empty_string /*PyObject *lnotab*/
285 );
286 if (!py_code) goto bad;
287 py_frame = PyFrame_New(
288 PyThreadState_Get(), /*PyThreadState *tstate,*/
289 py_code, /*PyCodeObject *code,*/
290 py_globals, /*PyObject *globals,*/
291 0 /*PyObject *locals*/
292 );
293 if (!py_frame) goto bad;
294 py_frame->f_lineno = __pyx_lineno;
295 PyTraceBack_Here(py_frame);
296 bad:
297 Py_XDECREF(py_srcfile);
298 Py_XDECREF(py_funcname);
299 Py_XDECREF(empty_tuple);
300 Py_XDECREF(empty_string);
301 Py_XDECREF(py_code);
302 Py_XDECREF(py_frame);
303 }
