Hi,

I cannot get the documented method to work::

  $ cat t.pyx
  cdef extern from "tupleobject.h":
      ctypedef class __builtin__.tuple [object PyTupleObject]:
          pass

  cdef class MyTuple(tuple):
      pass

  $ cython t.pyx
  warning: /tmp/t.pyx:2:4: tuple already a builtin Cython type
  $ gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c t.c -o t.o
  $ gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions t.o -o t.so

  $ python
  Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
  [GCC 4.3.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import t
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "t.pyx", line 2, in t (t.c:610)
      ctypedef class __builtin__.tuple [object PyTupleObject]:
  ValueError: __builtin__.tuple does not appear to be the correct type object

Relevant lines in t.c are::

  $ sed -e '547,551!d' t.c
    /*--- Function export code ---*/
    /*--- Type init code ---*/
    __pyx_ptype_1t_tuple = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME,
"tuple", sizeof(PyTupleObject)); if (unlikely(!__pyx_ptype_1t_tuple))
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno =
__LINE__; goto __pyx_L1_error;}
    __pyx_type_1t_MyTuple.tp_base = __pyx_ptype_1t_tuple;
    if (PyType_Ready(&__pyx_type_1t_MyTuple) < 0) {__pyx_filename =
__pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto
__pyx_L1_error;}

I'm using Cython 0.11.1; thanks for any help!

Best regards,
Riccardo

-- 
Riccardo Murri, via Rossée 17, 6987 Caslano (CH)
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to