Coder Social home page Coder Social logo

Cython 3 compatbility about music HOT 6 OPEN

sanjayankur31 avatar sanjayankur31 commented on September 28, 2024
Cython 3 compatbility

from music.

Comments (6)

hroncok avatar hroncok commented on September 28, 2024

In the Fedora RPM package I see:

Error compiling Cython file:
------------------------------------------------------------
...
            raise TypeError("object does not present buffer interface")

        cdef Py_buffer* pybuf = &self.pybuf
        PyObject_GetBuffer(data, pybuf, bufflags)
        self.dtype = TypeDict[getformat(pybuf)]
        self.items = pybuf.len / pybuf.itemsize
                               ^
------------------------------------------------------------

pybuffer.pyx:63:31: Cannot assign type 'double' to 'Py_ssize_t'

Cython 3 assumes Python 3 / semantics. This should be fixable by using //. Let me have a look.

from music.

hroncok avatar hroncok commented on September 28, 2024

f007845 (committed 2 years ago)

from music.

hroncok avatar hroncok commented on September 28, 2024

And then I get:

pymusic.cpp: In function 'PyObject* __pyx_pf_7pymusic_5Setup_6config(__pyx_obj_7pymusic_Setup*, std::string)':
pymusic.cpp:13679:45: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'PyObject*' {aka '_object*'}
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                                             ^~~~~~~~~~~~~~~~~~~~~~
pymusic.cpp:1512:43: note: in definition of macro 'likely'
 1512 |   #define likely(x)   __builtin_expect(!!(x), 1)
      |                                           ^
/usr/include/python3.12/object.h:194:28: note: in expansion of macro '_Py_CAST'
  194 | #define _PyObject_CAST(op) _Py_CAST(PyObject*, (op))
      |                            ^~~~~~~~
/usr/include/python3.12/object.h:254:43: note: in expansion of macro '_PyObject_CAST'
  254 | #  define Py_IS_TYPE(ob, type) Py_IS_TYPE(_PyObject_CAST(ob), (type))
      |                                           ^~~~~~~~~~~~~~
/usr/include/python3.12/floatobject.h:17:32: note: in expansion of macro 'Py_IS_TYPE'
   17 | #define PyFloat_CheckExact(op) Py_IS_TYPE((op), &PyFloat_Type)
      |                                ^~~~~~~~~~
pymusic.cpp:2870:10: note: in expansion of macro 'PyFloat_CheckExact'
 2870 | ((likely(PyFloat_CheckExact(obj))) ?  PyFloat_AS_DOUBLE(obj) :\
      |          ^~~~~~~~~~~~~~~~~~
pymusic.cpp:13679:20: note: in expansion of macro '__Pyx_PyObject_AsDouble'
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:38,
                 from pymusic.cpp:34:
pymusic.cpp:13679:45: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'PyObject*' {aka '_object*'}
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                                             ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/python3.12/pyport.h:24:38: note: in definition of macro '_Py_CAST'
   24 | #define _Py_CAST(type, expr) ((type)(expr))
      |                                      ^~~~
/usr/include/python3.12/cpython/floatobject.h:18:49: note: in expansion of macro '_PyObject_CAST'
   18 | #define PyFloat_AS_DOUBLE(op) PyFloat_AS_DOUBLE(_PyObject_CAST(op))
      |                                                 ^~~~~~~~~~~~~~
pymusic.cpp:2870:39: note: in expansion of macro 'PyFloat_AS_DOUBLE'
 2870 | ((likely(PyFloat_CheckExact(obj))) ?  PyFloat_AS_DOUBLE(obj) :\
      |                                       ^~~~~~~~~~~~~~~~~
pymusic.cpp:13679:20: note: in expansion of macro '__Pyx_PyObject_AsDouble'
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
pymusic.cpp:13679:45: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'PyObject*' {aka '_object*'}
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                                             ^~~~~~~~~~~~~~~~~~~~~~
pymusic.cpp:1512:43: note: in definition of macro 'likely'
 1512 |   #define likely(x)   __builtin_expect(!!(x), 1)
      |                                           ^
/usr/include/python3.12/object.h:194:28: note: in expansion of macro '_Py_CAST'
  194 | #define _PyObject_CAST(op) _Py_CAST(PyObject*, (op))
      |                            ^~~~~~~~
/usr/include/python3.12/object.h:254:43: note: in expansion of macro '_PyObject_CAST'
  254 | #  define Py_IS_TYPE(ob, type) Py_IS_TYPE(_PyObject_CAST(ob), (type))
      |                                           ^~~~~~~~~~~~~~
/usr/include/python3.12/longobject.h:14:31: note: in expansion of macro 'Py_IS_TYPE'
   14 | #define PyLong_CheckExact(op) Py_IS_TYPE((op), &PyLong_Type)
      |                               ^~~~~~~~~~
pymusic.cpp:2871:9: note: in expansion of macro 'PyLong_CheckExact'
 2871 |  likely(PyLong_CheckExact(obj)) ?\
      |         ^~~~~~~~~~~~~~~~~
pymusic.cpp:13679:20: note: in expansion of macro '__Pyx_PyObject_AsDouble'
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
pymusic.cpp:13679:45: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'PyObject*' {aka '_object*'}
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                                             ^~~~~~~~~~~~~~~~~~~~~~
pymusic.cpp:2872:18: note: in definition of macro '__Pyx_PyObject_AsDouble'
 2872 |  PyLong_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
      |                  ^~~
pymusic.cpp:13679:45: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'PyObject*' {aka '_object*'}
13679 |       __pyx_t_10 = __Pyx_PyObject_AsDouble(((PyObject *)__pyx_v_vs)); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L10_error)
      |                                             ^~~~~~~~~~~~~~~~~~~~~~
pymusic.cpp:2872:50: note: in definition of macro '__Pyx_PyObject_AsDouble'
 2872 |  PyLong_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
      |                                                  ^~~
pymusic.cpp: At global scope:
pymusic.cpp:25805:15: warning: 'double __Pyx__PyObject_AsDouble(PyObject*)' defined but not used [-Wunused-function]
25805 | static double __Pyx__PyObject_AsDouble(PyObject* obj) {
      |               ^~~~~~~~~~~~~~~~~~~~~~~~

from music.

hroncok avatar hroncok commented on September 28, 2024

I belive this might be a regression in Cython, I've opened cython/cython#5818

from music.

hroncok avatar hroncok commented on September 28, 2024

With cython/cython@bbbe428 Cython 3 works here.

from music.

sanjayankur31 avatar sanjayankur31 commented on September 28, 2024

I've got a WIP spec here, waiting on Cython 3.0.6:

https://bugzilla.redhat.com/show_bug.cgi?id=2224366

from music.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.