This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Cython is not compatible with Python 3.10 yet: "SystemError: bad argument to internal function"
Type: Stage: resolved
Components: Extension Modules, FreeBSD Versions: Python 3.10
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: AMDmi3, koobs, terry.reedy, vstinner
Priority: normal Keywords:

Created on 2021-04-09 13:44 by AMDmi3, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (6)
msg390621 - (view) Author: Dmitry Marakasov (AMDmi3) * Date: 2021-04-09 13:44
I'm playing with adding python3.10a7 port to FreeBSD ports collection, and have run into similar problem with building multiple third party modules (for instance, yaml, yarl and pystemmer). Here's log from yaml:

running build_ext
cythoning yaml/_yaml.pyx to yaml/_yaml.c
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "setup.py", line 271, in <module>
    setup(
  File "/usr/local/lib/python3.10/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/lib/python3.10/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/lib/python3.10/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python3.10/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 187, in run
    _build_ext.run(self)
  File "/usr/local/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/usr/local/lib/python3.10/distutils/command/build_ext.py", line 340, in run
    self.build_extensions()
  File "setup.py", line 229, in build_extensions
    ext.sources = self.cython_sources(ext.sources, ext)
  File "/usr/local/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py", line 346, in cython_sources
    result = cython_compile(source, options=options,
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Main.py", line 778, in compile
    return compile_single(source, options, full_module_name)
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Main.py", line 727, in compile_single
    return run_pipeline(source, options, full_module_name)
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Main.py", line 479, in run_pipeline
    context = options.create_context()
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Main.py", line 596, in create_context
    return Context(self.include_path, self.compiler_directives,
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Main.py", line 80, in __init__
    from . import Builtin, CythonScope
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/CythonScope.py", line 5, in <module>
    from .UtilityCode import CythonUtilityCode
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/UtilityCode.py", line 3, in <module>
    from .TreeFragment import parse_from_strings, StringParseContext
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/TreeFragment.py", line 17, in <module>
    from .Visitor import VisitorTransform
  File "Cython/Compiler/Visitor.py", line 17, in init Cython.Compiler.Visitor
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/ExprNodes.py", line 4742, in <module>
    class SliceIndexNode(ExprNode):
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/ExprNodes.py", line 4939, in SliceIndexNode
    get_slice_utility_code = TempitaUtilityCode.load(
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Code.py", line 404, in load
    return cls(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Code.py", line 645, in __init__
    proto = sub_tempita(proto, context, file, name)
  File "/usr/local/lib/python3.10/site-packages/Cython/Compiler/Code.py", line 638, in sub_tempita
    return sub(s, **context)
  File "Cython/Tempita/_tempita.py", line 376, in Cython.Tempita._tempita.sub
  File "Cython/Tempita/_tempita.py", line 137, in Cython.Tempita._tempita.Template.__init__
  File "Cython/Tempita/_tempita.py", line 819, in Cython.Tempita._tempita.parse
  File "Cython/Tempita/_tempita.py", line 661, in Cython.Tempita._tempita.lex
SystemError: Python/getargs.c:2038: bad argument to internal function
*** Error code 1
msg390624 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-09 13:47
Sadly, there is Cython release supporting Python 3.10 yet:
https://github.com/cython/cython/issues/4046

By the way, I propose two PRs to fix Cython tests on Python 3.10:
https://github.com/cython/cython/issues/4100

I suggest you waiting until there a new Cython release supporting Python 3.10.

In Fedora, we have downstream patches on Cython, we backported the Python 3.10 fixes:
https://src.fedoraproject.org/rpms/Cython/pull-request/28
msg390687 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-04-10 03:02
Does this issue propose a patch to python/cpython?  If not, it should be closed (and should have been posted to pydev list).
msg390737 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-10 19:54
This issue is a bug in Cython, not in Python. I close it.
msg390787 - (view) Author: Dmitry Marakasov (AMDmi3) * Date: 2021-04-11 15:38
> This issue is a bug in Cython, not in Python. I close it.

This is correct, thanks! The problem is gone with git master version of cython.
msg390831 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-04-12 09:57
> This is correct, thanks! The problem is gone with git master version of cython.

master is a different version. I suggest you trying the 0.29.x branch which is the actively maintained stable branch.
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 87958
2021-04-12 09:57:16vstinnersetmessages: + msg390831
2021-04-11 15:38:55AMDmi3setmessages: + msg390787
2021-04-10 19:54:40vstinnersetstatus: open -> closed
resolution: third party
messages: + msg390737

stage: resolved
2021-04-10 03:02:35terry.reedysetnosy: + terry.reedy
messages: + msg390687
2021-04-09 13:48:11vstinnersettitle: "bad argument to internal function" in cython -> Cython is not compatible with Python 3.10 yet: "SystemError: bad argument to internal function"
2021-04-09 13:47:43vstinnersetnosy: + vstinner
messages: + msg390624
2021-04-09 13:44:33AMDmi3create