Difference between Cython 3.2.0 and 3.1.6?

13 views
Skip to first unread message

Fredrik Bondesson

unread,
Nov 12, 2025, 1:09:05 PM (6 days ago) Nov 12
to cython-users
We have been using Cython 3.1.6 succesfully, however when trying to upgrade to 3.2.0 we ran into a problem.

The following code works on 3.1.6, however causes an AttributeError on 3.2.0:

....
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "cython_test.pyx", line 27, in cython_test.run_it
    print(f"SomeOtherError message: {error.description()}")
AttributeError: type object 'BaseException' has no attribute 'description'


setup.py:
from distutils.core import setup
from Cython.Build import cythonize


setup(name="Cython test", ext_modules=cythonize("cython_test.pyx"))

cython_test.pyx:
class Some_Error(RuntimeError):
    def __init__(self, error_str: str = ""):
        super().__init__(f"{error_str}")


class ErrorBase(Exception):
    def __init__(self, description: str) -> None:
        Exception.__init__(self)
        self._description = description

    def description(self) -> str:
        return self._description


class SomeOtherError(ErrorBase):
    def __init__(self, description: str) -> None:
        ErrorBase.__init__(self, description)


def try_except():
    try:
        raise Some_Error("error string")
    except Some_Error as error:
        raise SomeOtherError("Some other error") from error


def run_it():
    try:
        try_except()
    except SomeOtherError as error:
        print(f"SomeOtherError message: {error.description()}")

Steps to reproduce:
# py -3.10 -m venv venv
# venv\Scripts\activate.bat
# pip install Cython==3.2.0 / pip install Cython==3.1.6
# python setup.py build_ext --inplace
# python -c "from cython_test import run_it;run_it()"


Any advice? 
Do you consider this to be a bug?

Regards Fredrik
Reply all
Reply to author
Forward
0 new messages