Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflict with cython default branch #196

Closed
tacaswell opened this issue May 31, 2023 · 3 comments
Closed

conflict with cython default branch #196

tacaswell opened this issue May 31, 2023 · 3 comments

Comments

@tacaswell
Copy link

With the current (3.0.0b3-16-g03c498d31) cython default branch compliin fails with:


      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cdef readonly object func
          cdef readonly tuple args
          cdef readonly dict keywords
          cdef public object __doc__
          cdef public object __name__
          cdef public object __qualname__
                             ^
      ------------------------------------------------------------

      cytoolz/functoolz.pxd:18:23: '__qualname__' redeclared

      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cdef readonly object func
          cdef readonly tuple args
          cdef readonly dict keywords
          cdef public object __doc__
          cdef public object __name__
          cdef public object __qualname__
               ^
      ------------------------------------------------------------

      cytoolz/functoolz.pxd:18:9: Compiler crash in AnalyseDeclarationsTransform

      File 'ModuleNode.py', line 203, in analyse_declarations: ModuleNode(functoolz.pxd:1:0,
          full_module_name = 'cytoolz.functoolz',
          is_pxd = True)
      File 'Nodes.py', line 393, in analyse_declarations: StatListNode(functoolz.pxd:1:0)
      File 'Nodes.py', line 5425, in analyse_declarations: CClassDefNode(functoolz.pxd:10:5,
          as_name = 'curry',
          class_name = 'curry',
          in_pxd = True,
          module_name = '',
          punycode_class_name = 'curry',
          visibility = 'private')
      File 'Nodes.py', line 393, in analyse_declarations: StatListNode(functoolz.pxd:11:4)
      File 'Nodes.py', line 1529, in analyse_declarations: CVarDefNode(functoolz.pxd:18:9,
          in_pxd = True,
          modifiers = [...]/0,
          visibility = 'public')

      Compiler crash traceback from this point on:
        File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.13/site-packages/Cython/Compiler/Nodes.py", line 1529, in analyse_declarations
          self.entry = dest_scope.declare_var(
                       ^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.13/site-packages/Cython/Compiler/Symtab.py", line 2386, in declare_var
          entry = self.declare(name, cname, type, pos, visibility)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.13/site-packages/Cython/Compiler/Symtab.py", line 548, in declare
          entries[name].already_declared_here()
        File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.13/site-packages/Cython/Compiler/Symtab.py", line 260, in already_declared_here
          error(self.pos, "Previous declaration is here")
        File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.13/site-packages/Cython/Compiler/Errors.py", line 178, in error
          raise InternalError(message)

The following patch "fixes the build"

diff --git a/cytoolz/functoolz.pxd b/cytoolz/functoolz.pxd
index da203c1..c0dc62a 100644
--- a/cytoolz/functoolz.pxd
+++ b/cytoolz/functoolz.pxd
@@ -15,8 +15,6 @@ cdef class curry:
     cdef readonly dict keywords
     cdef public object __doc__
     cdef public object __name__
-    cdef public object __module__
-    cdef public object __qualname__


 cpdef object memoize(object func, object cache=*, object key=*)

but leaves functools broken:

______________________________________________________________________ ERROR collecting cytoolz/tests/dev_skip_test.py _______________________________________________________________________
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/python.py:532: in collect
    self._inject_setup_module_fixture()
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/python.py:546: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/python.py:311: in obj
    self._obj = obj = self._getobj()
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/python.py:529: in _getobj
    return self._importtestmodule()
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/python.py:618: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/pathlib.py:565: in import_path
    importlib.import_module(module_name)
../../../../.pybuild/bleeding/lib/python3.13/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1293: in _gcd_import
    ???
<frozen importlib._bootstrap>:1266: in _find_and_load
    ???
<frozen importlib._bootstrap>:1237: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:841: in _load_unlocked
    ???
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:172: in exec_module
    exec(co, module.__dict__)
cytoolz/tests/dev_skip_test.py:13: in <module>
    import cytoolz
../../../../.virtualenvs/bleeding/lib/python3.13/site-packages/cytoolz/__init__.py:19: in <module>
    flip = functoolz.flip = curry(functoolz.flip)
cytoolz/functoolz.pyx:214: in cytoolz.functoolz.curry.__cinit__
    self.__module__ = getattr(func, '__module__', None)
E   AttributeError: 'cytoolz.functoolz.curry' object has no attribute '__module__'

(a bunch of versions of that).

@tacaswell
Copy link
Author

I'm not sure if this is a cython regression or an intended change that cytoolz will have to deal with.

@eriknw
Copy link
Member

eriknw commented Jun 10, 2023

Thanks for the report! I'll look into a fix (since Cython 3.0 is immenent).

Perhaps we should add a CI scheduled job to run against upstream Cython.

@jrbourbeau
Copy link
Member

We now have a CI build that uses cython 3. I'm going to close this issue as resolved but feel free to re-open if this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants