Difference between Cython 3.2.0 and 3.1.6?

28 views
Skip to first unread message

Fredrik Bondesson

unread,
Nov 12, 2025, 1:09:05 PMNov 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

Fredrik Bondesson

unread,
Nov 26, 2025, 2:02:30 PM (13 days ago) Nov 26
to cython-users
And same error when trying with Cython 3.2.1 
:(

Any advice? Should I report this as a bug?

da-woods

unread,
Nov 26, 2025, 2:04:32 PM (13 days ago) Nov 26
to cython...@googlegroups.com

> Should I report this as a bug?

It's definitely a bug. The fix is already merged though and will be in 3.2.2 so no need to report it this time.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cython-users/e12d826a-4478-4a23-8866-4636f2c60b58n%40googlegroups.com.

Fredrik Bondesson

unread,
Nov 27, 2025, 2:40:30 AM (13 days ago) Nov 27
to cython-users
Thanks for the information!

Regards Fredrik
Reply all
Reply to author
Forward
0 new messages