pyrex

changeset 104:955ec491fcfc

Fix hex compile-time constants
author Gregory Ewing <greg.ewing@canterbury.ac.nz>
date Wed Aug 27 19:05:46 2008 +1200 (3 years ago)
parents 50dbbb4bc015
children 94d46b3c5354
files CHANGES.txt Pyrex/Compiler/ExprNodes.py Pyrex/Compiler/ModuleNode.py Tests/Bugs/devan/Reference/devan1.c Tests/Bugs/devan/devan1.c Tests/Bugs/devan/devan1.pyx
line diff
1.1 --- a/CHANGES.txt Wed Aug 27 18:26:36 2008 +1200 1.2 +++ b/CHANGES.txt Wed Aug 27 19:05:46 2008 +1200 1.3 @@ -12,6 +12,10 @@ 1.4 - MACOSX_DEPLOYMENT_TARGET is no longer set unless the undocumented -X 1.5 option is being used. Hopefully this will prevent complaints about it 1.6 from distutils. [Martin Field] 1.7 + 1.8 + - Recognize MS_WINDOWS as well as WIN32. [Alexander Belchenko] 1.9 + 1.10 + - Hexadecimal compile-time constants did not work. [Devan] 1.11 1.12 Enhancements: 1.13
2.1 --- a/Pyrex/Compiler/ExprNodes.py Wed Aug 27 18:26:36 2008 +1200 2.2 +++ b/Pyrex/Compiler/ExprNodes.py Wed Aug 27 19:05:46 2008 +1200 2.3 @@ -689,7 +689,7 @@ 2.4 type = PyrexTypes.c_long_type 2.5 2.6 def compile_time_value(self, denv): 2.7 - return int(self.value) 2.8 + return int(self.value, 0) 2.9 2.10 2.11 class FloatNode(ConstNode):
3.1 --- a/Pyrex/Compiler/ModuleNode.py Wed Aug 27 18:26:36 2008 +1200 3.2 +++ b/Pyrex/Compiler/ModuleNode.py Wed Aug 27 19:05:46 2008 +1200 3.3 @@ -316,7 +316,7 @@ 3.4 code.putln(" #define PyInt_FromSsize_t(z) PyInt_FromLong(z)") 3.5 code.putln(" #define PyInt_AsSsize_t(o) PyInt_AsLong(o)") 3.6 code.putln("#endif") 3.7 - code.putln("#ifndef WIN32") 3.8 + code.putln("#if !defined(WIN32) && !defined(MS_WINDOWS)") 3.9 code.putln(" #ifndef __stdcall") 3.10 code.putln(" #define __stdcall") 3.11 code.putln(" #endif")
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/Tests/Bugs/devan/Reference/devan1.c Wed Aug 27 19:05:46 2008 +1200 4.3 @@ -0,0 +1,242 @@ 4.4 +/* Generated by Pyrex 0.9.8.4 on Wed Aug 27 19:03:43 2008 */ 4.5 + 4.6 +#define PY_SSIZE_T_CLEAN 4.7 +#include "Python.h" 4.8 +#include "structmember.h" 4.9 +#ifndef PY_LONG_LONG 4.10 + #define PY_LONG_LONG LONG_LONG 4.11 +#endif 4.12 +#if PY_VERSION_HEX < 0x02050000 4.13 + typedef int Py_ssize_t; 4.14 + #define PY_SSIZE_T_MAX INT_MAX 4.15 + #define PY_SSIZE_T_MIN INT_MIN 4.16 + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) 4.17 + #define PyInt_AsSsize_t(o) PyInt_AsLong(o) 4.18 +#endif 4.19 +#if !defined(WIN32) && !defined(MS_WINDOWS) 4.20 + #ifndef __stdcall 4.21 + #define __stdcall 4.22 + #endif 4.23 + #ifndef __cdecl 4.24 + #define __cdecl 4.25 + #endif 4.26 +#endif 4.27 +#ifdef __cplusplus 4.28 +#define __PYX_EXTERN_C extern "C" 4.29 +#else 4.30 +#define __PYX_EXTERN_C extern 4.31 +#endif 4.32 +#include <math.h> 4.33 + 4.34 + 4.35 +typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ 4.36 + 4.37 +static PyObject *__pyx_m; 4.38 +static PyObject *__pyx_b; 4.39 +static int __pyx_lineno; 4.40 +static char *__pyx_filename; 4.41 +static char **__pyx_f; 4.42 + 4.43 +static int __Pyx_PrintItem(PyObject *); /*proto*/ 4.44 +static int __Pyx_PrintNewline(void); /*proto*/ 4.45 + 4.46 +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ 4.47 + 4.48 +static void __Pyx_AddTraceback(char *funcname); /*proto*/ 4.49 + 4.50 +/* Declarations from devan1 */ 4.51 + 4.52 + 4.53 +/* Declarations from implementation of devan1 */ 4.54 + 4.55 + 4.56 + 4.57 + 4.58 + 4.59 +static __Pyx_StringTabEntry __pyx_string_tab[] = { 4.60 + {0, 0, 0, 0} 4.61 +}; 4.62 + 4.63 + 4.64 + 4.65 +/* Implementation of devan1 */ 4.66 + 4.67 +static PyObject *__pyx_f_6devan1_print_constants(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 4.68 +static PyObject *__pyx_f_6devan1_print_constants(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 4.69 + PyObject *__pyx_r; 4.70 + PyObject *__pyx_1 = 0; 4.71 + static char *__pyx_argnames[] = {0}; 4.72 + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 4.73 + 4.74 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":6 */ 4.75 + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;} 4.76 + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;} 4.77 + Py_DECREF(__pyx_1); __pyx_1 = 0; 4.78 + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;} 4.79 + 4.80 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":7 */ 4.81 + __pyx_1 = PyInt_FromLong(16); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} 4.82 + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} 4.83 + Py_DECREF(__pyx_1); __pyx_1 = 0; 4.84 + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} 4.85 + 4.86 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":8 */ 4.87 + __pyx_1 = PyInt_FromLong(32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} 4.88 + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} 4.89 + Py_DECREF(__pyx_1); __pyx_1 = 0; 4.90 + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} 4.91 + 4.92 + __pyx_r = Py_None; Py_INCREF(Py_None); 4.93 + goto __pyx_L0; 4.94 + __pyx_L1:; 4.95 + Py_XDECREF(__pyx_1); 4.96 + __Pyx_AddTraceback("devan1.print_constants"); 4.97 + __pyx_r = 0; 4.98 + __pyx_L0:; 4.99 + return __pyx_r; 4.100 +} 4.101 + 4.102 +static struct PyMethodDef __pyx_methods[] = { 4.103 + {"print_constants", (PyCFunction)__pyx_f_6devan1_print_constants, METH_VARARGS|METH_KEYWORDS, 0}, 4.104 + {0, 0, 0, 0} 4.105 +}; 4.106 + 4.107 +static void __pyx_init_filenames(void); /*proto*/ 4.108 + 4.109 +PyMODINIT_FUNC initdevan1(void); /*proto*/ 4.110 +PyMODINIT_FUNC initdevan1(void) { 4.111 + __pyx_init_filenames(); 4.112 + __pyx_m = Py_InitModule4("devan1", __pyx_methods, 0, 0, PYTHON_API_VERSION); 4.113 + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 4.114 + Py_INCREF(__pyx_m); 4.115 + __pyx_b = PyImport_AddModule("__builtin__"); 4.116 + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 4.117 + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 4.118 + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 4.119 + 4.120 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":5 */ 4.121 + return; 4.122 + __pyx_L1:; 4.123 + __Pyx_AddTraceback("devan1"); 4.124 +} 4.125 + 4.126 +static char *__pyx_filenames[] = { 4.127 + "devan1.pyx", 4.128 +}; 4.129 + 4.130 +/* Runtime support code */ 4.131 + 4.132 +static void __pyx_init_filenames(void) { 4.133 + __pyx_f = __pyx_filenames; 4.134 +} 4.135 + 4.136 +static PyObject *__Pyx_GetStdout(void) { 4.137 + PyObject *f = PySys_GetObject("stdout"); 4.138 + if (!f) { 4.139 + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); 4.140 + } 4.141 + return f; 4.142 +} 4.143 + 4.144 +static int __Pyx_PrintItem(PyObject *v) { 4.145 + PyObject *f; 4.146 + 4.147 + if (!(f = __Pyx_GetStdout())) 4.148 + return -1; 4.149 + if (PyFile_SoftSpace(f, 1)) { 4.150 + if (PyFile_WriteString(" ", f) < 0) 4.151 + return -1; 4.152 + } 4.153 + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) 4.154 + return -1; 4.155 + if (PyString_Check(v)) { 4.156 + char *s = PyString_AsString(v); 4.157 + Py_ssize_t len = PyString_Size(v); 4.158 + if (len > 0 && 4.159 + isspace(Py_CHARMASK(s[len-1])) && 4.160 + s[len-1] != ' ') 4.161 + PyFile_SoftSpace(f, 0); 4.162 + } 4.163 + return 0; 4.164 +} 4.165 + 4.166 +static int __Pyx_PrintNewline(void) { 4.167 + PyObject *f; 4.168 + 4.169 + if (!(f = __Pyx_GetStdout())) 4.170 + return -1; 4.171 + if (PyFile_WriteString("\n", f) < 0) 4.172 + return -1; 4.173 + PyFile_SoftSpace(f, 0); 4.174 + return 0; 4.175 +} 4.176 + 4.177 +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 4.178 + while (t->p) { 4.179 + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 4.180 + if (!*t->p) 4.181 + return -1; 4.182 + if (t->i) 4.183 + PyString_InternInPlace(t->p); 4.184 + ++t; 4.185 + } 4.186 + return 0; 4.187 +} 4.188 + 4.189 +#include "compile.h" 4.190 +#include "frameobject.h" 4.191 +#include "traceback.h" 4.192 + 4.193 +static void __Pyx_AddTraceback(char *funcname) { 4.194 + PyObject *py_srcfile = 0; 4.195 + PyObject *py_funcname = 0; 4.196 + PyObject *py_globals = 0; 4.197 + PyObject *empty_tuple = 0; 4.198 + PyObject *empty_string = 0; 4.199 + PyCodeObject *py_code = 0; 4.200 + PyFrameObject *py_frame = 0; 4.201 + 4.202 + py_srcfile = PyString_FromString(__pyx_filename); 4.203 + if (!py_srcfile) goto bad; 4.204 + py_funcname = PyString_FromString(funcname); 4.205 + if (!py_funcname) goto bad; 4.206 + py_globals = PyModule_GetDict(__pyx_m); 4.207 + if (!py_globals) goto bad; 4.208 + empty_tuple = PyTuple_New(0); 4.209 + if (!empty_tuple) goto bad; 4.210 + empty_string = PyString_FromString(""); 4.211 + if (!empty_string) goto bad; 4.212 + py_code = PyCode_New( 4.213 + 0, /*int argcount,*/ 4.214 + 0, /*int nlocals,*/ 4.215 + 0, /*int stacksize,*/ 4.216 + 0, /*int flags,*/ 4.217 + empty_string, /*PyObject *code,*/ 4.218 + empty_tuple, /*PyObject *consts,*/ 4.219 + empty_tuple, /*PyObject *names,*/ 4.220 + empty_tuple, /*PyObject *varnames,*/ 4.221 + empty_tuple, /*PyObject *freevars,*/ 4.222 + empty_tuple, /*PyObject *cellvars,*/ 4.223 + py_srcfile, /*PyObject *filename,*/ 4.224 + py_funcname, /*PyObject *name,*/ 4.225 + __pyx_lineno, /*int firstlineno,*/ 4.226 + empty_string /*PyObject *lnotab*/ 4.227 + ); 4.228 + if (!py_code) goto bad; 4.229 + py_frame = PyFrame_New( 4.230 + PyThreadState_Get(), /*PyThreadState *tstate,*/ 4.231 + py_code, /*PyCodeObject *code,*/ 4.232 + py_globals, /*PyObject *globals,*/ 4.233 + 0 /*PyObject *locals*/ 4.234 + ); 4.235 + if (!py_frame) goto bad; 4.236 + py_frame->f_lineno = __pyx_lineno; 4.237 + PyTraceBack_Here(py_frame); 4.238 +bad: 4.239 + Py_XDECREF(py_srcfile); 4.240 + Py_XDECREF(py_funcname); 4.241 + Py_XDECREF(empty_tuple); 4.242 + Py_XDECREF(empty_string); 4.243 + Py_XDECREF(py_code); 4.244 + Py_XDECREF(py_frame); 4.245 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/Tests/Bugs/devan/devan1.c Wed Aug 27 19:05:46 2008 +1200 5.3 @@ -0,0 +1,242 @@ 5.4 +/* Generated by Pyrex 0.9.8.4 on Wed Aug 27 19:03:43 2008 */ 5.5 + 5.6 +#define PY_SSIZE_T_CLEAN 5.7 +#include "Python.h" 5.8 +#include "structmember.h" 5.9 +#ifndef PY_LONG_LONG 5.10 + #define PY_LONG_LONG LONG_LONG 5.11 +#endif 5.12 +#if PY_VERSION_HEX < 0x02050000 5.13 + typedef int Py_ssize_t; 5.14 + #define PY_SSIZE_T_MAX INT_MAX 5.15 + #define PY_SSIZE_T_MIN INT_MIN 5.16 + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) 5.17 + #define PyInt_AsSsize_t(o) PyInt_AsLong(o) 5.18 +#endif 5.19 +#if !defined(WIN32) && !defined(MS_WINDOWS) 5.20 + #ifndef __stdcall 5.21 + #define __stdcall 5.22 + #endif 5.23 + #ifndef __cdecl 5.24 + #define __cdecl 5.25 + #endif 5.26 +#endif 5.27 +#ifdef __cplusplus 5.28 +#define __PYX_EXTERN_C extern "C" 5.29 +#else 5.30 +#define __PYX_EXTERN_C extern 5.31 +#endif 5.32 +#include <math.h> 5.33 + 5.34 + 5.35 +typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ 5.36 + 5.37 +static PyObject *__pyx_m; 5.38 +static PyObject *__pyx_b; 5.39 +static int __pyx_lineno; 5.40 +static char *__pyx_filename; 5.41 +static char **__pyx_f; 5.42 + 5.43 +static int __Pyx_PrintItem(PyObject *); /*proto*/ 5.44 +static int __Pyx_PrintNewline(void); /*proto*/ 5.45 + 5.46 +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ 5.47 + 5.48 +static void __Pyx_AddTraceback(char *funcname); /*proto*/ 5.49 + 5.50 +/* Declarations from devan1 */ 5.51 + 5.52 + 5.53 +/* Declarations from implementation of devan1 */ 5.54 + 5.55 + 5.56 + 5.57 + 5.58 + 5.59 +static __Pyx_StringTabEntry __pyx_string_tab[] = { 5.60 + {0, 0, 0, 0} 5.61 +}; 5.62 + 5.63 + 5.64 + 5.65 +/* Implementation of devan1 */ 5.66 + 5.67 +static PyObject *__pyx_f_6devan1_print_constants(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 5.68 +static PyObject *__pyx_f_6devan1_print_constants(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 5.69 + PyObject *__pyx_r; 5.70 + PyObject *__pyx_1 = 0; 5.71 + static char *__pyx_argnames[] = {0}; 5.72 + if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 5.73 + 5.74 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":6 */ 5.75 + __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;} 5.76 + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;} 5.77 + Py_DECREF(__pyx_1); __pyx_1 = 0; 5.78 + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;} 5.79 + 5.80 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":7 */ 5.81 + __pyx_1 = PyInt_FromLong(16); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} 5.82 + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} 5.83 + Py_DECREF(__pyx_1); __pyx_1 = 0; 5.84 + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;} 5.85 + 5.86 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":8 */ 5.87 + __pyx_1 = PyInt_FromLong(32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} 5.88 + if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} 5.89 + Py_DECREF(__pyx_1); __pyx_1 = 0; 5.90 + if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;} 5.91 + 5.92 + __pyx_r = Py_None; Py_INCREF(Py_None); 5.93 + goto __pyx_L0; 5.94 + __pyx_L1:; 5.95 + Py_XDECREF(__pyx_1); 5.96 + __Pyx_AddTraceback("devan1.print_constants"); 5.97 + __pyx_r = 0; 5.98 + __pyx_L0:; 5.99 + return __pyx_r; 5.100 +} 5.101 + 5.102 +static struct PyMethodDef __pyx_methods[] = { 5.103 + {"print_constants", (PyCFunction)__pyx_f_6devan1_print_constants, METH_VARARGS|METH_KEYWORDS, 0}, 5.104 + {0, 0, 0, 0} 5.105 +}; 5.106 + 5.107 +static void __pyx_init_filenames(void); /*proto*/ 5.108 + 5.109 +PyMODINIT_FUNC initdevan1(void); /*proto*/ 5.110 +PyMODINIT_FUNC initdevan1(void) { 5.111 + __pyx_init_filenames(); 5.112 + __pyx_m = Py_InitModule4("devan1", __pyx_methods, 0, 0, PYTHON_API_VERSION); 5.113 + if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 5.114 + Py_INCREF(__pyx_m); 5.115 + __pyx_b = PyImport_AddModule("__builtin__"); 5.116 + if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 5.117 + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 5.118 + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}; 5.119 + 5.120 + /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/devan/devan1.pyx":5 */ 5.121 + return; 5.122 + __pyx_L1:; 5.123 + __Pyx_AddTraceback("devan1"); 5.124 +} 5.125 + 5.126 +static char *__pyx_filenames[] = { 5.127 + "devan1.pyx", 5.128 +}; 5.129 + 5.130 +/* Runtime support code */ 5.131 + 5.132 +static void __pyx_init_filenames(void) { 5.133 + __pyx_f = __pyx_filenames; 5.134 +} 5.135 + 5.136 +static PyObject *__Pyx_GetStdout(void) { 5.137 + PyObject *f = PySys_GetObject("stdout"); 5.138 + if (!f) { 5.139 + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); 5.140 + } 5.141 + return f; 5.142 +} 5.143 + 5.144 +static int __Pyx_PrintItem(PyObject *v) { 5.145 + PyObject *f; 5.146 + 5.147 + if (!(f = __Pyx_GetStdout())) 5.148 + return -1; 5.149 + if (PyFile_SoftSpace(f, 1)) { 5.150 + if (PyFile_WriteString(" ", f) < 0) 5.151 + return -1; 5.152 + } 5.153 + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) 5.154 + return -1; 5.155 + if (PyString_Check(v)) { 5.156 + char *s = PyString_AsString(v); 5.157 + Py_ssize_t len = PyString_Size(v); 5.158 + if (len > 0 && 5.159 + isspace(Py_CHARMASK(s[len-1])) && 5.160 + s[len-1] != ' ') 5.161 + PyFile_SoftSpace(f, 0); 5.162 + } 5.163 + return 0; 5.164 +} 5.165 + 5.166 +static int __Pyx_PrintNewline(void) { 5.167 + PyObject *f; 5.168 + 5.169 + if (!(f = __Pyx_GetStdout())) 5.170 + return -1; 5.171 + if (PyFile_WriteString("\n", f) < 0) 5.172 + return -1; 5.173 + PyFile_SoftSpace(f, 0); 5.174 + return 0; 5.175 +} 5.176 + 5.177 +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 5.178 + while (t->p) { 5.179 + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 5.180 + if (!*t->p) 5.181 + return -1; 5.182 + if (t->i) 5.183 + PyString_InternInPlace(t->p); 5.184 + ++t; 5.185 + } 5.186 + return 0; 5.187 +} 5.188 + 5.189 +#include "compile.h" 5.190 +#include "frameobject.h" 5.191 +#include "traceback.h" 5.192 + 5.193 +static void __Pyx_AddTraceback(char *funcname) { 5.194 + PyObject *py_srcfile = 0; 5.195 + PyObject *py_funcname = 0; 5.196 + PyObject *py_globals = 0; 5.197 + PyObject *empty_tuple = 0; 5.198 + PyObject *empty_string = 0; 5.199 + PyCodeObject *py_code = 0; 5.200 + PyFrameObject *py_frame = 0; 5.201 + 5.202 + py_srcfile = PyString_FromString(__pyx_filename); 5.203 + if (!py_srcfile) goto bad; 5.204 + py_funcname = PyString_FromString(funcname); 5.205 + if (!py_funcname) goto bad; 5.206 + py_globals = PyModule_GetDict(__pyx_m); 5.207 + if (!py_globals) goto bad; 5.208 + empty_tuple = PyTuple_New(0); 5.209 + if (!empty_tuple) goto bad; 5.210 + empty_string = PyString_FromString(""); 5.211 + if (!empty_string) goto bad; 5.212 + py_code = PyCode_New( 5.213 + 0, /*int argcount,*/ 5.214 + 0, /*int nlocals,*/ 5.215 + 0, /*int stacksize,*/ 5.216 + 0, /*int flags,*/ 5.217 + empty_string, /*PyObject *code,*/ 5.218 + empty_tuple, /*PyObject *consts,*/ 5.219 + empty_tuple, /*PyObject *names,*/ 5.220 + empty_tuple, /*PyObject *varnames,*/ 5.221 + empty_tuple, /*PyObject *freevars,*/ 5.222 + empty_tuple, /*PyObject *cellvars,*/ 5.223 + py_srcfile, /*PyObject *filename,*/ 5.224 + py_funcname, /*PyObject *name,*/ 5.225 + __pyx_lineno, /*int firstlineno,*/ 5.226 + empty_string /*PyObject *lnotab*/ 5.227 + ); 5.228 + if (!py_code) goto bad; 5.229 + py_frame = PyFrame_New( 5.230 + PyThreadState_Get(), /*PyThreadState *tstate,*/ 5.231 + py_code, /*PyCodeObject *code,*/ 5.232 + py_globals, /*PyObject *globals,*/ 5.233 + 0 /*PyObject *locals*/ 5.234 + ); 5.235 + if (!py_frame) goto bad; 5.236 + py_frame->f_lineno = __pyx_lineno; 5.237 + PyTraceBack_Here(py_frame); 5.238 +bad: 5.239 + Py_XDECREF(py_srcfile); 5.240 + Py_XDECREF(py_funcname); 5.241 + Py_XDECREF(empty_tuple); 5.242 + Py_XDECREF(empty_string); 5.243 + Py_XDECREF(py_code); 5.244 + Py_XDECREF(py_frame); 5.245 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/Tests/Bugs/devan/devan1.pyx Wed Aug 27 19:05:46 2008 +1200 6.3 @@ -0,0 +1,8 @@ 6.4 +DEF SPAM = 2 6.5 +DEF FOO = 0x10 6.6 +DEF BAR = 0x20 6.7 + 6.8 +def print_constants(): 6.9 + print SPAM 6.10 + print FOO 6.11 + print BAR