Commits

gcewing  committed e6a912f

Fixed ctypedef public api class

  • Participants
  • Parent commits c3c8da7

Comments (0)

Files changed (16)

 
 	- Function export code was erroneously generated for 'extern' functions
 		declared in a .pxd file. [Sebastian Sable]
+	
+	- The 'api' option was not recognised with 'ctypedef public class'.
+		[Lisandro Dalcin]
 
 Enhancements:
 

File Pyrex/Compiler/Parsing.py

 	if s.sy == 'ctypedef':
 		if ctx.level not in ('module', 'module_pxd'):
 			s.error("ctypedef statement not allowed here")
-		if ctx.api:
-			error(s.pos, "'api' not allowed with 'ctypedef'")
+		#if ctx.api:
+		#	error(s.pos, "'api' not allowed with 'ctypedef'")
 		return p_ctypedef_statement(s, ctx)
 	elif s.sy == 'DEF':
 		return p_DEF_statement(s)
 	pos = s.position()
 	s.next()
 	visibility = p_visibility(s, ctx.visibility)
+	api = p_api(s)
 	ctx = ctx(typedef_flag = 1, visibility = visibility)
+	if api:
+		ctx.api = 1
 	if s.sy == 'class':
 		return p_c_class_definition(s, pos, ctx)
 	elif s.sy == 'IDENT' and s.systring in ('struct', 'union', 'enum'):

File Tests/Bugs/dalcin/Reference/dalcin1.c

+/* Generated by Pyrex 0.9.8.2 on Sun Jun  8 16:28:46 2008 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
+#endif
+#ifndef WIN32
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+
+
+typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static int __pyx_lineno;
+static char *__pyx_filename;
+static char **__pyx_f;
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+static void __Pyx_AddTraceback(char *funcname); /*proto*/
+
+/* Declarations from dalcin1 */
+
+
+/* Declarations from implementation of dalcin1 */
+
+static int __pyx_f_7dalcin1_obj2int(PyObject *); /*proto*/
+
+
+
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {0, 0, 0, 0}
+};
+
+
+
+/* Implementation of dalcin1 */
+
+static int __pyx_f_7dalcin1_obj2int(PyObject *__pyx_v_ob) {
+  int __pyx_r;
+  int __pyx_1;
+  Py_INCREF(__pyx_v_ob);
+  __pyx_1 = PyInt_AsLong(__pyx_v_ob); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
+  __pyx_r = __pyx_1;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1:;
+  __Pyx_AddTraceback("dalcin1.obj2int");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_ob);
+  return __pyx_r;
+}
+
+static struct PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+static void __pyx_init_filenames(void); /*proto*/
+
+PyMODINIT_FUNC initdalcin1(void); /*proto*/
+PyMODINIT_FUNC initdalcin1(void) {
+  __pyx_init_filenames();
+  __pyx_m = Py_InitModule4("dalcin1", __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  Py_INCREF(__pyx_m);
+  __pyx_b = PyImport_AddModule("__builtin__");
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  return;
+  __pyx_L1:;
+  __Pyx_AddTraceback("dalcin1");
+}
+
+static char *__pyx_filenames[] = {
+  "dalcin1.pyx",
+};
+
+/* Runtime support code */
+
+static void __pyx_init_filenames(void) {
+  __pyx_f = __pyx_filenames;
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+	while (t->p) {
+		*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+		if (!*t->p)
+			return -1;
+		if (t->i)
+			PyString_InternInPlace(t->p);
+		++t;
+	}
+	return 0;
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(char *funcname) {
+	PyObject *py_srcfile = 0;
+	PyObject *py_funcname = 0;
+	PyObject *py_globals = 0;
+	PyObject *empty_tuple = 0;
+	PyObject *empty_string = 0;
+	PyCodeObject *py_code = 0;
+	PyFrameObject *py_frame = 0;
+	
+	py_srcfile = PyString_FromString(__pyx_filename);
+	if (!py_srcfile) goto bad;
+	py_funcname = PyString_FromString(funcname);
+	if (!py_funcname) goto bad;
+	py_globals = PyModule_GetDict(__pyx_m);
+	if (!py_globals) goto bad;
+	empty_tuple = PyTuple_New(0);
+	if (!empty_tuple) goto bad;
+	empty_string = PyString_FromString("");
+	if (!empty_string) goto bad;
+	py_code = PyCode_New(
+		0,            /*int argcount,*/
+		0,            /*int nlocals,*/
+		0,            /*int stacksize,*/
+		0,            /*int flags,*/
+		empty_string, /*PyObject *code,*/
+		empty_tuple,  /*PyObject *consts,*/
+		empty_tuple,  /*PyObject *names,*/
+		empty_tuple,  /*PyObject *varnames,*/
+		empty_tuple,  /*PyObject *freevars,*/
+		empty_tuple,  /*PyObject *cellvars,*/
+		py_srcfile,   /*PyObject *filename,*/
+		py_funcname,  /*PyObject *name,*/
+		__pyx_lineno,   /*int firstlineno,*/
+		empty_string  /*PyObject *lnotab*/
+	);
+	if (!py_code) goto bad;
+	py_frame = PyFrame_New(
+		PyThreadState_Get(), /*PyThreadState *tstate,*/
+		py_code,             /*PyCodeObject *code,*/
+		py_globals,          /*PyObject *globals,*/
+		0                    /*PyObject *locals*/
+	);
+	if (!py_frame) goto bad;
+	py_frame->f_lineno = __pyx_lineno;
+	PyTraceBack_Here(py_frame);
+bad:
+	Py_XDECREF(py_srcfile);
+	Py_XDECREF(py_funcname);
+	Py_XDECREF(empty_tuple);
+	Py_XDECREF(empty_string);
+	Py_XDECREF(py_code);
+	Py_XDECREF(py_frame);
+}

File Tests/Bugs/dalcin/Reference/dalcin2.c

+/* Generated by Pyrex 0.9.8.4 on Wed Aug 27 17:42:02 2008 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
+#endif
+#ifndef WIN32
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+
+
+typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static int __pyx_lineno;
+static char *__pyx_filename;
+static char **__pyx_f;
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+static void __Pyx_AddTraceback(char *funcname); /*proto*/
+
+/* Declarations from dalcin2 */
+
+
+/* Declarations from implementation of dalcin2 */
+
+typedef struct {
+  PyObject_HEAD
+} PyFooObject;
+
+__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyFoo_Type;
+
+static PyTypeObject *__pyx_ptype_7dalcin2_Foo = 0;
+
+
+
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {0, 0, 0, 0}
+};
+
+
+
+/* Implementation of dalcin2 */
+
+static PyObject *__pyx_tp_new_7dalcin2_Foo(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  return o;
+}
+
+static void __pyx_tp_dealloc_7dalcin2_Foo(PyObject *o) {
+  (*o->ob_type->tp_free)(o);
+}
+
+static struct PyMethodDef __pyx_methods_7dalcin2_Foo[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Foo = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  0, /*nb_divide*/
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  0, /*nb_coerce*/
+  0, /*nb_int*/
+  0, /*nb_long*/
+  0, /*nb_float*/
+  0, /*nb_oct*/
+  0, /*nb_hex*/
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  0, /*nb_inplace_divide*/
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_Foo = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_Foo = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Foo = {
+  0, /*bf_getreadbuffer*/
+  0, /*bf_getwritebuffer*/
+  0, /*bf_getsegcount*/
+  0, /*bf_getcharbuffer*/
+};
+
+DL_EXPORT(PyTypeObject) PyFoo_Type = {
+  PyObject_HEAD_INIT(0)
+  0, /*ob_size*/
+  "dalcin2.Foo", /*tp_name*/
+  sizeof(PyFooObject), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7dalcin2_Foo, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  0, /*tp_compare*/
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_Foo, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Foo, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Foo, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_Foo, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+  0, /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7dalcin2_Foo, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7dalcin2_Foo, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+};
+
+static struct PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+static void __pyx_init_filenames(void); /*proto*/
+
+PyMODINIT_FUNC initdalcin2(void); /*proto*/
+PyMODINIT_FUNC initdalcin2(void) {
+  __pyx_init_filenames();
+  __pyx_m = Py_InitModule4("dalcin2", __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  Py_INCREF(__pyx_m);
+  __pyx_b = PyImport_AddModule("__builtin__");
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (PyType_Ready(&PyFoo_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
+  if (PyObject_SetAttrString(__pyx_m, "Foo", (PyObject *)&PyFoo_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
+  __pyx_ptype_7dalcin2_Foo = &PyFoo_Type;
+  return;
+  __pyx_L1:;
+  __Pyx_AddTraceback("dalcin2");
+}
+
+static char *__pyx_filenames[] = {
+  "dalcin2.pyx",
+};
+
+/* Runtime support code */
+
+static void __pyx_init_filenames(void) {
+  __pyx_f = __pyx_filenames;
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+	while (t->p) {
+		*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+		if (!*t->p)
+			return -1;
+		if (t->i)
+			PyString_InternInPlace(t->p);
+		++t;
+	}
+	return 0;
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(char *funcname) {
+	PyObject *py_srcfile = 0;
+	PyObject *py_funcname = 0;
+	PyObject *py_globals = 0;
+	PyObject *empty_tuple = 0;
+	PyObject *empty_string = 0;
+	PyCodeObject *py_code = 0;
+	PyFrameObject *py_frame = 0;
+	
+	py_srcfile = PyString_FromString(__pyx_filename);
+	if (!py_srcfile) goto bad;
+	py_funcname = PyString_FromString(funcname);
+	if (!py_funcname) goto bad;
+	py_globals = PyModule_GetDict(__pyx_m);
+	if (!py_globals) goto bad;
+	empty_tuple = PyTuple_New(0);
+	if (!empty_tuple) goto bad;
+	empty_string = PyString_FromString("");
+	if (!empty_string) goto bad;
+	py_code = PyCode_New(
+		0,            /*int argcount,*/
+		0,            /*int nlocals,*/
+		0,            /*int stacksize,*/
+		0,            /*int flags,*/
+		empty_string, /*PyObject *code,*/
+		empty_tuple,  /*PyObject *consts,*/
+		empty_tuple,  /*PyObject *names,*/
+		empty_tuple,  /*PyObject *varnames,*/
+		empty_tuple,  /*PyObject *freevars,*/
+		empty_tuple,  /*PyObject *cellvars,*/
+		py_srcfile,   /*PyObject *filename,*/
+		py_funcname,  /*PyObject *name,*/
+		__pyx_lineno,   /*int firstlineno,*/
+		empty_string  /*PyObject *lnotab*/
+	);
+	if (!py_code) goto bad;
+	py_frame = PyFrame_New(
+		PyThreadState_Get(), /*PyThreadState *tstate,*/
+		py_code,             /*PyCodeObject *code,*/
+		py_globals,          /*PyObject *globals,*/
+		0                    /*PyObject *locals*/
+	);
+	if (!py_frame) goto bad;
+	py_frame->f_lineno = __pyx_lineno;
+	PyTraceBack_Here(py_frame);
+bad:
+	Py_XDECREF(py_srcfile);
+	Py_XDECREF(py_funcname);
+	Py_XDECREF(empty_tuple);
+	Py_XDECREF(empty_string);
+	Py_XDECREF(py_code);
+	Py_XDECREF(py_frame);
+}

File Tests/Bugs/dalcin/Reference/dalcin2.h

+#ifndef __PYX_HAVE__dalcin2
+#define __PYX_HAVE__dalcin2
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+
+typedef struct {
+  PyObject_HEAD
+} PyFooObject;
+
+#ifndef __PYX_HAVE_API__dalcin2
+
+__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyFoo_Type;
+
+#endif
+
+PyMODINIT_FUNC initdalcin2(void);
+
+#endif

File Tests/Bugs/dalcin/Reference/dalcin2_api.h

+#ifndef __PYX_HAVE_API__dalcin2
+#define __PYX_HAVE_API__dalcin2
+#include "Python.h"
+#include "dalcin2.h"
+
+static PyTypeObject *__pyx_ptype_7dalcin2_Foo;
+#define PyFoo_Type (*__pyx_ptype_7dalcin2_Foo)
+
+#ifndef __PYX_HAVE_API_FUNC_import_module
+#define __PYX_HAVE_API_FUNC_import_module
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(char *name) {
+	PyObject *py_name = 0;
+	
+	py_name = PyString_FromString(name);
+	if (!py_name)
+		goto bad;
+	return PyImport_Import(py_name);
+bad:
+	Py_XDECREF(py_name);
+	return 0;
+}
+#endif
+
+#endif
+
+
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, 
+	long size) 
+{
+	PyObject *py_module = 0;
+	PyObject *result = 0;
+	
+	py_module = __Pyx_ImportModule(module_name);
+	if (!py_module)
+		goto bad;
+	result = PyObject_GetAttrString(py_module, class_name);
+	if (!result)
+		goto bad;
+	if (!PyType_Check(result)) {
+		PyErr_Format(PyExc_TypeError, 
+			"%s.%s is not a type object",
+			module_name, class_name);
+		goto bad;
+	}
+	if (((PyTypeObject *)result)->tp_basicsize != size) {
+		PyErr_Format(PyExc_ValueError, 
+			"%s.%s does not appear to be the correct type object",
+			module_name, class_name);
+		goto bad;
+	}
+	return (PyTypeObject *)result;
+bad:
+	Py_XDECREF(result);
+	return 0;
+}
+#endif
+
+static int import_dalcin2(void) {
+  PyObject *module = 0;
+  module = __Pyx_ImportModule("dalcin2");
+  if (!module) goto bad;
+  Py_DECREF(module); module = 0;
+  __pyx_ptype_7dalcin2_Foo = __Pyx_ImportType("dalcin2", "Foo", sizeof(PyFooObject)); if (!__pyx_ptype_7dalcin2_Foo) goto bad;
+  return 0;
+  bad:
+  Py_XDECREF(module);
+  return -1;
+}
+
+#endif

File Tests/Bugs/dalcin/dalcin1.c

+/* Generated by Pyrex */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
+#endif
+#ifndef WIN32
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+
+
+typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static int __pyx_lineno;
+static char *__pyx_filename;
+static char **__pyx_f;
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+static void __Pyx_AddTraceback(char *funcname); /*proto*/
+
+/* Declarations from dalcin1 */
+
+
+/* Declarations from implementation of dalcin1 */
+
+static int __pyx_f_7dalcin1_obj2int(PyObject *); /*proto*/
+
+
+
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {0, 0, 0, 0}
+};
+
+
+
+/* Implementation of dalcin1 */
+
+static int __pyx_f_7dalcin1_obj2int(PyObject *__pyx_v_ob) {
+  int __pyx_r;
+  int __pyx_1;
+  Py_INCREF(__pyx_v_ob);
+  __pyx_1 = PyInt_AsLong(__pyx_v_ob); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
+  __pyx_r = __pyx_1;
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1:;
+  __Pyx_AddTraceback("dalcin1.obj2int");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_ob);
+  return __pyx_r;
+}
+
+static struct PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+static void __pyx_init_filenames(void); /*proto*/
+
+PyMODINIT_FUNC initdalcin1(void); /*proto*/
+PyMODINIT_FUNC initdalcin1(void) {
+  __pyx_init_filenames();
+  __pyx_m = Py_InitModule4("dalcin1", __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  Py_INCREF(__pyx_m);
+  __pyx_b = PyImport_AddModule("__builtin__");
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  return;
+  __pyx_L1:;
+  __Pyx_AddTraceback("dalcin1");
+}
+
+static char *__pyx_filenames[] = {
+  "dalcin1.pyx",
+};
+
+/* Runtime support code */
+
+static void __pyx_init_filenames(void) {
+  __pyx_f = __pyx_filenames;
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+	while (t->p) {
+		*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+		if (!*t->p)
+			return -1;
+		if (t->i)
+			PyString_InternInPlace(t->p);
+		++t;
+	}
+	return 0;
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(char *funcname) {
+	PyObject *py_srcfile = 0;
+	PyObject *py_funcname = 0;
+	PyObject *py_globals = 0;
+	PyObject *empty_tuple = 0;
+	PyObject *empty_string = 0;
+	PyCodeObject *py_code = 0;
+	PyFrameObject *py_frame = 0;
+	
+	py_srcfile = PyString_FromString(__pyx_filename);
+	if (!py_srcfile) goto bad;
+	py_funcname = PyString_FromString(funcname);
+	if (!py_funcname) goto bad;
+	py_globals = PyModule_GetDict(__pyx_m);
+	if (!py_globals) goto bad;
+	empty_tuple = PyTuple_New(0);
+	if (!empty_tuple) goto bad;
+	empty_string = PyString_FromString("");
+	if (!empty_string) goto bad;
+	py_code = PyCode_New(
+		0,            /*int argcount,*/
+		0,            /*int nlocals,*/
+		0,            /*int stacksize,*/
+		0,            /*int flags,*/
+		empty_string, /*PyObject *code,*/
+		empty_tuple,  /*PyObject *consts,*/
+		empty_tuple,  /*PyObject *names,*/
+		empty_tuple,  /*PyObject *varnames,*/
+		empty_tuple,  /*PyObject *freevars,*/
+		empty_tuple,  /*PyObject *cellvars,*/
+		py_srcfile,   /*PyObject *filename,*/
+		py_funcname,  /*PyObject *name,*/
+		__pyx_lineno,   /*int firstlineno,*/
+		empty_string  /*PyObject *lnotab*/
+	);
+	if (!py_code) goto bad;
+	py_frame = PyFrame_New(
+		PyThreadState_Get(), /*PyThreadState *tstate,*/
+		py_code,             /*PyCodeObject *code,*/
+		py_globals,          /*PyObject *globals,*/
+		0                    /*PyObject *locals*/
+	);
+	if (!py_frame) goto bad;
+	py_frame->f_lineno = __pyx_lineno;
+	PyTraceBack_Here(py_frame);
+bad:
+	Py_XDECREF(py_srcfile);
+	Py_XDECREF(py_funcname);
+	Py_XDECREF(empty_tuple);
+	Py_XDECREF(empty_string);
+	Py_XDECREF(py_code);
+	Py_XDECREF(py_frame);
+}

File Tests/Bugs/dalcin/dalcin1.pyx

+cdef int obj2int(object ob) except *:
+	return ob

File Tests/Bugs/dalcin/dalcin2.c

+/* Generated by Pyrex 0.9.8.4 on Wed Aug 27 17:42:02 2008 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
+#endif
+#ifndef WIN32
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+
+
+typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static int __pyx_lineno;
+static char *__pyx_filename;
+static char **__pyx_f;
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+static void __Pyx_AddTraceback(char *funcname); /*proto*/
+
+/* Declarations from dalcin2 */
+
+
+/* Declarations from implementation of dalcin2 */
+
+typedef struct {
+  PyObject_HEAD
+} PyFooObject;
+
+__PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyFoo_Type;
+
+static PyTypeObject *__pyx_ptype_7dalcin2_Foo = 0;
+
+
+
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {0, 0, 0, 0}
+};
+
+
+
+/* Implementation of dalcin2 */
+
+static PyObject *__pyx_tp_new_7dalcin2_Foo(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  return o;
+}
+
+static void __pyx_tp_dealloc_7dalcin2_Foo(PyObject *o) {
+  (*o->ob_type->tp_free)(o);
+}
+
+static struct PyMethodDef __pyx_methods_7dalcin2_Foo[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Foo = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  0, /*nb_divide*/
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  0, /*nb_coerce*/
+  0, /*nb_int*/
+  0, /*nb_long*/
+  0, /*nb_float*/
+  0, /*nb_oct*/
+  0, /*nb_hex*/
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  0, /*nb_inplace_divide*/
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_Foo = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_Foo = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Foo = {
+  0, /*bf_getreadbuffer*/
+  0, /*bf_getwritebuffer*/
+  0, /*bf_getsegcount*/
+  0, /*bf_getcharbuffer*/
+};
+
+DL_EXPORT(PyTypeObject) PyFoo_Type = {
+  PyObject_HEAD_INIT(0)
+  0, /*ob_size*/
+  "dalcin2.Foo", /*tp_name*/
+  sizeof(PyFooObject), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_7dalcin2_Foo, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  0, /*tp_compare*/
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_Foo, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Foo, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Foo, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_Foo, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+  0, /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_7dalcin2_Foo, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_7dalcin2_Foo, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+};
+
+static struct PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+static void __pyx_init_filenames(void); /*proto*/
+
+PyMODINIT_FUNC initdalcin2(void); /*proto*/
+PyMODINIT_FUNC initdalcin2(void) {
+  __pyx_init_filenames();
+  __pyx_m = Py_InitModule4("dalcin2", __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  Py_INCREF(__pyx_m);
+  __pyx_b = PyImport_AddModule("__builtin__");
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+  if (PyType_Ready(&PyFoo_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
+  if (PyObject_SetAttrString(__pyx_m, "Foo", (PyObject *)&PyFoo_Type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
+  __pyx_ptype_7dalcin2_Foo = &PyFoo_Type;
+  return;
+  __pyx_L1:;
+  __Pyx_AddTraceback("dalcin2");
+}
+
+static char *__pyx_filenames[] = {
+  "dalcin2.pyx",
+};
+
+/* Runtime support code */
+
+static void __pyx_init_filenames(void) {
+  __pyx_f = __pyx_filenames;
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+	while (t->p) {
+		*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+		if (!*t->p)
+			return -1;
+		if (t->i)
+			PyString_InternInPlace(t->p);
+		++t;
+	}
+	return 0;
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(char *funcname) {
+	PyObject *py_srcfile = 0;
+	PyObject *py_funcname = 0;
+	PyObject *py_globals = 0;
+	PyObject *empty_tuple = 0;
+	PyObject *empty_string = 0;
+	PyCodeObject *py_code = 0;
+	PyFrameObject *py_frame = 0;
+	
+	py_srcfile = PyString_FromString(__pyx_filename);
+	if (!py_srcfile) goto bad;
+	py_funcname = PyString_FromString(funcname);
+	if (!py_funcname) goto bad;
+	py_globals = PyModule_GetDict(__pyx_m);
+	if (!py_globals) goto bad;
+	empty_tuple = PyTuple_New(0);
+	if (!empty_tuple) goto bad;
+	empty_string = PyString_FromString("");
+	if (!empty_string) goto bad;
+	py_code = PyCode_New(
+		0,            /*int argcount,*/
+		0,            /*int nlocals,*/
+		0,            /*int stacksize,*/
+		0,            /*int flags,*/
+		empty_string, /*PyObject *code,*/
+		empty_tuple,  /*PyObject *consts,*/
+		empty_tuple,  /*PyObject *names,*/
+		empty_tuple,  /*PyObject *varnames,*/
+		empty_tuple,  /*PyObject *freevars,*/
+		empty_tuple,  /*PyObject *cellvars,*/
+		py_srcfile,   /*PyObject *filename,*/
+		py_funcname,  /*PyObject *name,*/
+		__pyx_lineno,   /*int firstlineno,*/
+		empty_string  /*PyObject *lnotab*/
+	);
+	if (!py_code) goto bad;
+	py_frame = PyFrame_New(
+		PyThreadState_Get(), /*PyThreadState *tstate,*/
+		py_code,             /*PyCodeObject *code,*/
+		py_globals,          /*PyObject *globals,*/
+		0                    /*PyObject *locals*/
+	);
+	if (!py_frame) goto bad;
+	py_frame->f_lineno = __pyx_lineno;
+	PyTraceBack_Here(py_frame);
+bad:
+	Py_XDECREF(py_srcfile);
+	Py_XDECREF(py_funcname);
+	Py_XDECREF(empty_tuple);
+	Py_XDECREF(empty_string);
+	Py_XDECREF(py_code);
+	Py_XDECREF(py_frame);
+}

File Tests/Bugs/dalcin/dalcin2.h

+#ifndef __PYX_HAVE__dalcin2
+#define __PYX_HAVE__dalcin2
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+
+typedef struct {
+  PyObject_HEAD
+} PyFooObject;
+
+#ifndef __PYX_HAVE_API__dalcin2
+
+__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyFoo_Type;
+
+#endif
+
+PyMODINIT_FUNC initdalcin2(void);
+
+#endif

File Tests/Bugs/dalcin/dalcin2.pyx

+ctypedef public api class Foo [type PyFoo_Type, object PyFooObject]:
+	pass

File Tests/Bugs/dalcin/dalcin2_api.h

+#ifndef __PYX_HAVE_API__dalcin2
+#define __PYX_HAVE_API__dalcin2
+#include "Python.h"
+#include "dalcin2.h"
+
+static PyTypeObject *__pyx_ptype_7dalcin2_Foo;
+#define PyFoo_Type (*__pyx_ptype_7dalcin2_Foo)
+
+#ifndef __PYX_HAVE_API_FUNC_import_module
+#define __PYX_HAVE_API_FUNC_import_module
+
+#ifndef __PYX_HAVE_RT_ImportModule
+#define __PYX_HAVE_RT_ImportModule
+static PyObject *__Pyx_ImportModule(char *name) {
+	PyObject *py_name = 0;
+	
+	py_name = PyString_FromString(name);
+	if (!py_name)
+		goto bad;
+	return PyImport_Import(py_name);
+bad:
+	Py_XDECREF(py_name);
+	return 0;
+}
+#endif
+
+#endif
+
+
+#ifndef __PYX_HAVE_RT_ImportType
+#define __PYX_HAVE_RT_ImportType
+static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, 
+	long size) 
+{
+	PyObject *py_module = 0;
+	PyObject *result = 0;
+	
+	py_module = __Pyx_ImportModule(module_name);
+	if (!py_module)
+		goto bad;
+	result = PyObject_GetAttrString(py_module, class_name);
+	if (!result)
+		goto bad;
+	if (!PyType_Check(result)) {
+		PyErr_Format(PyExc_TypeError, 
+			"%s.%s is not a type object",
+			module_name, class_name);
+		goto bad;
+	}
+	if (((PyTypeObject *)result)->tp_basicsize != size) {
+		PyErr_Format(PyExc_ValueError, 
+			"%s.%s does not appear to be the correct type object",
+			module_name, class_name);
+		goto bad;
+	}
+	return (PyTypeObject *)result;
+bad:
+	Py_XDECREF(result);
+	return 0;
+}
+#endif
+
+static int import_dalcin2(void) {
+  PyObject *module = 0;
+  module = __Pyx_ImportModule("dalcin2");
+  if (!module) goto bad;
+  Py_DECREF(module); module = 0;
+  __pyx_ptype_7dalcin2_Foo = __Pyx_ImportType("dalcin2", "Foo", sizeof(PyFooObject)); if (!__pyx_ptype_7dalcin2_Foo) goto bad;
+  return 0;
+  bad:
+  Py_XDECREF(module);
+  return -1;
+}
+
+#endif

File Tests/Bugs/other/.DS_Store

Binary file modified.

File Tests/Bugs/other/Reference/dalcin1.c

-/* Generated by Pyrex 0.9.8.2 on Sun Jun  8 16:28:46 2008 */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#include "structmember.h"
-#ifndef PY_LONG_LONG
-  #define PY_LONG_LONG LONG_LONG
-#endif
-#if PY_VERSION_HEX < 0x02050000
-  typedef int Py_ssize_t;
-  #define PY_SSIZE_T_MAX INT_MAX
-  #define PY_SSIZE_T_MIN INT_MIN
-  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
-  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
-#endif
-#ifndef WIN32
-  #ifndef __stdcall
-    #define __stdcall
-  #endif
-  #ifndef __cdecl
-    #define __cdecl
-  #endif
-#endif
-#ifdef __cplusplus
-#define __PYX_EXTERN_C extern "C"
-#else
-#define __PYX_EXTERN_C extern
-#endif
-#include <math.h>
-
-
-typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
-
-static PyObject *__pyx_m;
-static PyObject *__pyx_b;
-static int __pyx_lineno;
-static char *__pyx_filename;
-static char **__pyx_f;
-
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
-
-static void __Pyx_AddTraceback(char *funcname); /*proto*/
-
-/* Declarations from dalcin1 */
-
-
-/* Declarations from implementation of dalcin1 */
-
-static int __pyx_f_7dalcin1_obj2int(PyObject *); /*proto*/
-
-
-
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
-  {0, 0, 0, 0}
-};
-
-
-
-/* Implementation of dalcin1 */
-
-static int __pyx_f_7dalcin1_obj2int(PyObject *__pyx_v_ob) {
-  int __pyx_r;
-  int __pyx_1;
-  Py_INCREF(__pyx_v_ob);
-  __pyx_1 = PyInt_AsLong(__pyx_v_ob); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
-  __pyx_r = __pyx_1;
-  goto __pyx_L0;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1:;
-  __Pyx_AddTraceback("dalcin1.obj2int");
-  __pyx_r = 0;
-  __pyx_L0:;
-  Py_DECREF(__pyx_v_ob);
-  return __pyx_r;
-}
-
-static struct PyMethodDef __pyx_methods[] = {
-  {0, 0, 0, 0}
-};
-
-static void __pyx_init_filenames(void); /*proto*/
-
-PyMODINIT_FUNC initdalcin1(void); /*proto*/
-PyMODINIT_FUNC initdalcin1(void) {
-  __pyx_init_filenames();
-  __pyx_m = Py_InitModule4("dalcin1", __pyx_methods, 0, 0, PYTHON_API_VERSION);
-  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  Py_INCREF(__pyx_m);
-  __pyx_b = PyImport_AddModule("__builtin__");
-  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  return;
-  __pyx_L1:;
-  __Pyx_AddTraceback("dalcin1");
-}
-
-static char *__pyx_filenames[] = {
-  "dalcin1.pyx",
-};
-
-/* Runtime support code */
-
-static void __pyx_init_filenames(void) {
-  __pyx_f = __pyx_filenames;
-}
-
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
-	while (t->p) {
-		*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
-		if (!*t->p)
-			return -1;
-		if (t->i)
-			PyString_InternInPlace(t->p);
-		++t;
-	}
-	return 0;
-}
-
-#include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-
-static void __Pyx_AddTraceback(char *funcname) {
-	PyObject *py_srcfile = 0;
-	PyObject *py_funcname = 0;
-	PyObject *py_globals = 0;
-	PyObject *empty_tuple = 0;
-	PyObject *empty_string = 0;
-	PyCodeObject *py_code = 0;
-	PyFrameObject *py_frame = 0;
-	
-	py_srcfile = PyString_FromString(__pyx_filename);
-	if (!py_srcfile) goto bad;
-	py_funcname = PyString_FromString(funcname);
-	if (!py_funcname) goto bad;
-	py_globals = PyModule_GetDict(__pyx_m);
-	if (!py_globals) goto bad;
-	empty_tuple = PyTuple_New(0);
-	if (!empty_tuple) goto bad;
-	empty_string = PyString_FromString("");
-	if (!empty_string) goto bad;
-	py_code = PyCode_New(
-		0,            /*int argcount,*/
-		0,            /*int nlocals,*/
-		0,            /*int stacksize,*/
-		0,            /*int flags,*/
-		empty_string, /*PyObject *code,*/
-		empty_tuple,  /*PyObject *consts,*/
-		empty_tuple,  /*PyObject *names,*/
-		empty_tuple,  /*PyObject *varnames,*/
-		empty_tuple,  /*PyObject *freevars,*/
-		empty_tuple,  /*PyObject *cellvars,*/
-		py_srcfile,   /*PyObject *filename,*/
-		py_funcname,  /*PyObject *name,*/
-		__pyx_lineno,   /*int firstlineno,*/
-		empty_string  /*PyObject *lnotab*/
-	);
-	if (!py_code) goto bad;
-	py_frame = PyFrame_New(
-		PyThreadState_Get(), /*PyThreadState *tstate,*/
-		py_code,             /*PyCodeObject *code,*/
-		py_globals,          /*PyObject *globals,*/
-		0                    /*PyObject *locals*/
-	);
-	if (!py_frame) goto bad;
-	py_frame->f_lineno = __pyx_lineno;
-	PyTraceBack_Here(py_frame);
-bad:
-	Py_XDECREF(py_srcfile);
-	Py_XDECREF(py_funcname);
-	Py_XDECREF(empty_tuple);
-	Py_XDECREF(empty_string);
-	Py_XDECREF(py_code);
-	Py_XDECREF(py_frame);
-}

File Tests/Bugs/other/dalcin1.c

-/* Generated by Pyrex */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#include "structmember.h"
-#ifndef PY_LONG_LONG
-  #define PY_LONG_LONG LONG_LONG
-#endif
-#if PY_VERSION_HEX < 0x02050000
-  typedef int Py_ssize_t;
-  #define PY_SSIZE_T_MAX INT_MAX
-  #define PY_SSIZE_T_MIN INT_MIN
-  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
-  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
-#endif
-#ifndef WIN32
-  #ifndef __stdcall
-    #define __stdcall
-  #endif
-  #ifndef __cdecl
-    #define __cdecl
-  #endif
-#endif
-#ifdef __cplusplus
-#define __PYX_EXTERN_C extern "C"
-#else
-#define __PYX_EXTERN_C extern
-#endif
-#include <math.h>
-
-
-typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
-
-static PyObject *__pyx_m;
-static PyObject *__pyx_b;
-static int __pyx_lineno;
-static char *__pyx_filename;
-static char **__pyx_f;
-
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
-
-static void __Pyx_AddTraceback(char *funcname); /*proto*/
-
-/* Declarations from dalcin1 */
-
-
-/* Declarations from implementation of dalcin1 */
-
-static int __pyx_f_7dalcin1_obj2int(PyObject *); /*proto*/
-
-
-
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
-  {0, 0, 0, 0}
-};
-
-
-
-/* Implementation of dalcin1 */
-
-static int __pyx_f_7dalcin1_obj2int(PyObject *__pyx_v_ob) {
-  int __pyx_r;
-  int __pyx_1;
-  Py_INCREF(__pyx_v_ob);
-  __pyx_1 = PyInt_AsLong(__pyx_v_ob); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
-  __pyx_r = __pyx_1;
-  goto __pyx_L0;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1:;
-  __Pyx_AddTraceback("dalcin1.obj2int");
-  __pyx_r = 0;
-  __pyx_L0:;
-  Py_DECREF(__pyx_v_ob);
-  return __pyx_r;
-}
-
-static struct PyMethodDef __pyx_methods[] = {
-  {0, 0, 0, 0}
-};
-
-static void __pyx_init_filenames(void); /*proto*/
-
-PyMODINIT_FUNC initdalcin1(void); /*proto*/
-PyMODINIT_FUNC initdalcin1(void) {
-  __pyx_init_filenames();
-  __pyx_m = Py_InitModule4("dalcin1", __pyx_methods, 0, 0, PYTHON_API_VERSION);
-  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  Py_INCREF(__pyx_m);
-  __pyx_b = PyImport_AddModule("__builtin__");
-  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
-  return;
-  __pyx_L1:;
-  __Pyx_AddTraceback("dalcin1");
-}
-
-static char *__pyx_filenames[] = {
-  "dalcin1.pyx",
-};
-
-/* Runtime support code */
-
-static void __pyx_init_filenames(void) {
-  __pyx_f = __pyx_filenames;
-}
-
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
-	while (t->p) {
-		*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
-		if (!*t->p)
-			return -1;
-		if (t->i)
-			PyString_InternInPlace(t->p);
-		++t;
-	}
-	return 0;
-}
-
-#include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-
-static void __Pyx_AddTraceback(char *funcname) {
-	PyObject *py_srcfile = 0;
-	PyObject *py_funcname = 0;
-	PyObject *py_globals = 0;
-	PyObject *empty_tuple = 0;
-	PyObject *empty_string = 0;
-	PyCodeObject *py_code = 0;
-	PyFrameObject *py_frame = 0;
-	
-	py_srcfile = PyString_FromString(__pyx_filename);
-	if (!py_srcfile) goto bad;
-	py_funcname = PyString_FromString(funcname);
-	if (!py_funcname) goto bad;
-	py_globals = PyModule_GetDict(__pyx_m);
-	if (!py_globals) goto bad;
-	empty_tuple = PyTuple_New(0);
-	if (!empty_tuple) goto bad;
-	empty_string = PyString_FromString("");
-	if (!empty_string) goto bad;
-	py_code = PyCode_New(
-		0,            /*int argcount,*/
-		0,            /*int nlocals,*/
-		0,            /*int stacksize,*/
-		0,            /*int flags,*/
-		empty_string, /*PyObject *code,*/
-		empty_tuple,  /*PyObject *consts,*/
-		empty_tuple,  /*PyObject *names,*/
-		empty_tuple,  /*PyObject *varnames,*/
-		empty_tuple,  /*PyObject *freevars,*/
-		empty_tuple,  /*PyObject *cellvars,*/
-		py_srcfile,   /*PyObject *filename,*/
-		py_funcname,  /*PyObject *name,*/
-		__pyx_lineno,   /*int firstlineno,*/
-		empty_string  /*PyObject *lnotab*/
-	);
-	if (!py_code) goto bad;
-	py_frame = PyFrame_New(
-		PyThreadState_Get(), /*PyThreadState *tstate,*/
-		py_code,             /*PyCodeObject *code,*/
-		py_globals,          /*PyObject *globals,*/
-		0                    /*PyObject *locals*/
-	);
-	if (!py_frame) goto bad;
-	py_frame->f_lineno = __pyx_lineno;
-	PyTraceBack_Here(py_frame);
-bad:
-	Py_XDECREF(py_srcfile);
-	Py_XDECREF(py_funcname);
-	Py_XDECREF(empty_tuple);
-	Py_XDECREF(empty_string);
-	Py_XDECREF(py_code);
-	Py_XDECREF(py_frame);
-}

File Tests/Bugs/other/dalcin1.pyx

-cdef int obj2int(object ob) except *:
-	return ob