Repository: cython/cython

Issue:
[BUG] Duplicate `__Pyx_PyInt_As_int` functions
### Describe the bug

We are having an issue when migrating to recent Cython 3.0.  The compiler issues the next error:

```
/Users/faltet/blosc/python-blosc2/_skbuild/macosx-13.0-arm64-3.11/cmake-build/blosc2/blosc2_ext.c:71562:28: error: redefinition of '__Pyx_PyInt_As_int'
  static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
                           ^
/Users/faltet/blosc/python-blosc2/_skbuild/macosx-13.0-arm64-3.11/cmake-build/blosc2/blosc2_ext.c:69734:28: note: previous definition is here
  static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
                           ^
2 warnings and 1 error generated.
make[2]: *** [blosc2/CMakeFiles/blosc2_ext.dir/blosc2_ext.c.o] Error 1
make[1]: *** [blosc2/CMakeFiles/blosc2_ext.dir/all] Error 2
make: *** [all] Error 2

```

### Code to reproduce the behaviour:

You can reproduce the issue by going to the python-blosc2 project at: https://github.com/Blosc/python-blosc2 and compile the extension with regular:

```bash
python setup.py build_ext -j 8 -i
```

### Expected behaviour

We are expecting a successful compilation.  Actually, we are using Cython < 3 for many years, and never had this issue before.

### OS

macOSX, Linux

### Python version

any

### Cython version

3.0.0

### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py
--- a/Cython/Compiler/PyrexTypes.py
+++ b/Cython/Compiler/PyrexTypes.py
@@ -59,7 +59,8 @@ def specialization_name(self):
         if self._specialization_name is None:
             # This is not entirely robust.
             common_subs = (self.empty_declaration_code()
-                           .replace("unsigned ", "unsigned_")
+                           # covers both "unsigned " and "signed "
+                           .replace("signed ", "signed_")
                            .replace("long long", "long_long")
                            .replace(" ", "__"))
             self._specialization_name = re.sub(
@@ -2189,6 +2190,11 @@ class CAnonEnumType(CIntType):
     def sign_and_name(self):
         return 'int'
 
+    def specialization_name(self):
+        # ensure that the to/from Python functions don't conflict with
+        # "int"
+        return '__pyx_anon_enum'
+
 
 class CReturnCodeType(CIntType):
 
@@ -2198,6 +2204,11 @@ class CReturnCodeType(CIntType):
     exception_check = False
     default_format_spec = ''
 
+    def specialization_name(self):
+        # I don't think we should end up creating PyInt_As_int/PyInt_From_int functions
+        # for this type, but it's better they're distinct in case it happens.
+        return super(CReturnCodeType, self).specialization_name() + "return_code"
+
     def can_coerce_to_pystring(self, env, format_spec=None):
         return not format_spec
 


Test patch:
diff --git a/tests/run/c_int_types_T255.pyx b/tests/run/c_int_types_T255.pyx
--- a/tests/run/c_int_types_T255.pyx
+++ b/tests/run/c_int_types_T255.pyx
@@ -187,7 +187,7 @@ def test_add_short(x, y):
 SSHORT_MAX = <signed short>((<unsigned short>-1)>>1)
 SSHORT_MIN = (-SSHORT_MAX-1)
 
-def test_sshort(short x):
+def test_sshort(signed short x):
    u"""
    >>> test_sshort(SSHORT_MIN-1) #doctest: +ELLIPSIS
    Traceback (most recent call last):
@@ -765,6 +765,20 @@ def test_convert_pylong(x):
    cdef long long r = x
    return r
 
+
+cdef enum:
+   ANONYMOUS_ENUM_MEMBER = 1
+
+def test_anonymous_enum():
+   """
+   The main point here is that the from-py conversion function shouldn't
+   conflict with the function for int
+   >>> test_anonymous_enum()
+   1
+   """
+   return ANONYMOUS_ENUM_MEMBER
+
+
 # -------------------------------------------------------------------
 
 __doc__ = u"".join([