Bug 2093909 - pythran fails to build with Python 3.11: TypeError: Random.shuffle() takes 2 positional arguments but 3 were given
Summary: pythran fails to build with Python 3.11: TypeError: Random.shuffle() takes 2 ...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: pythran
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2022-06-06 11:00 UTC by Tomáš Hrnčiar
Modified: 2022-06-22 11:49 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-06-22 11:49:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github serge-sans-paille pythran issues 1995 0 None open Python 3.11: TypeError: Random.shuffle() takes 2 positional arguments but 3 were given 2022-06-06 11:15:03 UTC

Description Tomáš Hrnčiar 2022-06-06 11:00:58 UTC
pythran fails to build with Python 3.11.0b3.

=================================== FAILURES ===================================
___________________________ TestRandom.test_shuffle2 ___________________________
[gw1] linux -- Python 3.11.0 /usr/bin/python3

self = <pythran.tests.test_random.TestRandom testMethod=test_shuffle2>

    def test_shuffle2(self):
        """ Check shuffling with custom function. """
>       self.run_test("""
        def shuffle2(n):
            from random import shuffle
            r = list(range(n))
            shuffle(r, lambda: 0)
            return r != list(range(n)) and sorted(r) == list(range(n))""",
                      10 ** 4, shuffle2=[int])

pythran/tests/test_random.py:114: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pythran/tests/__init__.py:316: in run_test
    python_ref = self.run_python(code, (name, copy.deepcopy(params)),
pythran/tests/__init__.py:173: in run_python
    ret_val = env[runas[0]](*runas[1])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

n = 10000

>   ???
E   TypeError: Random.shuffle() takes 2 positional arguments but 3 were given

<string>:5: TypeError
----------------------------- Captured stdout call -----------------------------
running build_ext
DEBUG: new_compiler returns <class 'distutils.unixccompiler.UnixCCompiler'>
building 'test_shuffle2' extension
INFO: C compiler: g++ -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC

creating /tmp/tmp_2lf150h/tmp
INFO: compile options: '-DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_OPENBLAS -I/usr/include/flexiblas -I/builddir/build/BUILD/pythran-0.11.0/pythran -I/usr/lib64/python3.11/site-packages/numpy/core/include -I/usr/include/python3.11 -c'
extra options: '-std=c++11 -fno-math-errno -fvisibility=hidden -fno-wrapv -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O1 -Wall -w -UNDEBUG -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option -Wno-unused-local-typedefs -Wno-absolute-value -Wno-missing-braces -Wno-unknown-pragmas'
INFO: g++: /tmp/tmp22nk9hzs.cpp
INFO: g++ -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -Wl,--build-id=sha1 -g -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -Wl,--build-id=sha1 -g -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/pythran-0.11.0/.package_note-pythran-0.11.0-4.fc37.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection /tmp/tmp_2lf150h/tmp/tmp22nk9hzs.o -L/usr/lib64 -L/usr/lib64 -lflexiblas -lflexiblas -lflexiblas -o /tmp/tmpfw7cubkp/test_shuffle2.cpython-311-x86_64-linux-gnu.so -fvisibility=hidden -Wl,-strip-all -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/pythran-0.11.0/.package_note-pythran-0.11.0-4.fc37.x86_64.ld
----------------------------- Captured stderr call -----------------------------
cc1plus: warning: command-line option ‘-Wno-absolute-value’ is valid for C/ObjC but not for C++
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
INFO: Generated module: test_shuffle2
INFO: Output: /builddir/build/BUILD/pythran-0.11.0/test_shuffle2.cpython-311-x86_64-linux-gnu.so
------------------------------ Captured log call -------------------------------
INFO     pythran:toolchain.py:340 Generated module: test_shuffle2
INFO     pythran:toolchain.py:341 Output: /builddir/build/BUILD/pythran-0.11.0/test_shuffle2.cpython-311-x86_64-linux-gnu.so
___________________________ TestRandom.test_shuffle3 ___________________________
[gw1] linux -- Python 3.11.0 /usr/bin/python3

self = <pythran.tests.test_random.TestRandom testMethod=test_shuffle3>

    def test_shuffle3(self):
        """ Check shuffling with random function. """
>       self.run_test("""
        def shuffle3(n):
            from random import shuffle, random
            r = list(range(n))
            shuffle(r, random)
            return r != list(range(n)) and sorted(r) == list(range(n))""",
                      10 ** 4, shuffle3=[int])

pythran/tests/test_random.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pythran/tests/__init__.py:316: in run_test
    python_ref = self.run_python(code, (name, copy.deepcopy(params)),
pythran/tests/__init__.py:173: in run_python
    ret_val = env[runas[0]](*runas[1])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

n = 10000

>   ???
E   TypeError: Random.shuffle() takes 2 positional arguments but 3 were given

<string>:5: TypeError
----------------------------- Captured stdout call -----------------------------
running build_ext
DEBUG: new_compiler returns <class 'distutils.unixccompiler.UnixCCompiler'>
building 'test_shuffle3' extension
INFO: C compiler: g++ -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC

creating /tmp/tmp948j4mz6/tmp
INFO: compile options: '-DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_OPENBLAS -I/usr/include/flexiblas -I/builddir/build/BUILD/pythran-0.11.0/pythran -I/usr/lib64/python3.11/site-packages/numpy/core/include -I/usr/include/python3.11 -c'
extra options: '-std=c++11 -fno-math-errno -fvisibility=hidden -fno-wrapv -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O1 -Wall -w -UNDEBUG -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option -Wno-unused-local-typedefs -Wno-absolute-value -Wno-missing-braces -Wno-unknown-pragmas'
INFO: g++: /tmp/tmpflieyj4z.cpp
INFO: g++ -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -Wl,--build-id=sha1 -g -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -Wl,--build-id=sha1 -g -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/pythran-0.11.0/.package_note-pythran-0.11.0-4.fc37.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection /tmp/tmp948j4mz6/tmp/tmpflieyj4z.o -L/usr/lib64 -L/usr/lib64 -lflexiblas -lflexiblas -lflexiblas -o /tmp/tmphwxb_aoe/test_shuffle3.cpython-311-x86_64-linux-gnu.so -fvisibility=hidden -Wl,-strip-all -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/pythran-0.11.0/.package_note-pythran-0.11.0-4.fc37.x86_64.ld
----------------------------- Captured stderr call -----------------------------
cc1plus: warning: command-line option ‘-Wno-absolute-value’ is valid for C/ObjC but not for C++
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
INFO: Generated module: test_shuffle3
INFO: Output: /builddir/build/BUILD/pythran-0.11.0/test_shuffle3.cpython-311-x86_64-linux-gnu.so
------------------------------ Captured log call -------------------------------
INFO     pythran:toolchain.py:340 Generated module: test_shuffle3
INFO     pythran:toolchain.py:341 Output: /builddir/build/BUILD/pythran-0.11.0/test_shuffle3.cpython-311-x86_64-linux-gnu.so
__________________________ TestDoctest.test_toolchain __________________________
[gw0] linux -- Python 3.11.0 /usr/bin/python3

self = <pythran.tests.test_xdoc.TestDoctest testMethod=test_toolchain>

>   lambda self: generic_test_package(self, module))

pythran/tests/test_xdoc.py:89: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pythran/tests/test_xdoc.py:83: in generic_test_package
    self.assertEqual(failed, 0)
E   AssertionError: 2 != 0
----------------------------- Captured stdout call -----------------------------
**********************************************************************
File "/builddir/build/BUILD/pythran-0.11.0/pythran/toolchain.py", line 454, in pythran.toolchain.compile_pythranfile
Failed example:
    ext = sysconfig.get_config_vars()["SO"]
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python3.11/doctest.py", line 1350, in __run
        exec(compile(example.source, filename, "single",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest pythran.toolchain.compile_pythranfile[5]>", line 1, in <module>
        ext = sysconfig.get_config_vars()["SO"]
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
    KeyError: 'SO'
**********************************************************************
File "/builddir/build/BUILD/pythran-0.11.0/pythran/toolchain.py", line 455, in pythran.toolchain.compile_pythranfile
Failed example:
    so_path = compile_pythranfile('pythran_test.py', output_file='foo'+ext)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python3.11/doctest.py", line 1350, in __run
        exec(compile(example.source, filename, "single",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest pythran.toolchain.compile_pythranfile[6]>", line 1, in <module>
        so_path = compile_pythranfile('pythran_test.py', output_file='foo'+ext)
                                                                           ^^^
    NameError: name 'ext' is not defined
**********************************************************************
1 items had failures:
   2 of   7 in pythran.toolchain.compile_pythranfile
***Test Failed*** 2 failures.
------------------------------ Captured log call -------------------------------
WARNING  root:spec.py:94 No pythran specification, nothing will be exported
=============================== warnings summary ===============================
...snip...
=========================== short test summary info ============================
FAILED pythran/tests/test_random.py::TestRandom::test_shuffle2 - TypeError: R...
FAILED pythran/tests/test_random.py::TestRandom::test_shuffle3 - TypeError: R...
FAILED pythran/tests/test_xdoc.py::TestDoctest::test_toolchain - AssertionErr...
==== 3 failed, 3468 passed, 49 skipped, 547 warnings in 15989.35s (4:26:29) ====

https://docs.python.org/3.11/whatsnew/3.11.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/04499501-pythran/

For all our attempts to build pythran with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/pythran/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2022-06-06 11:15:04 UTC
Reported to upstream: https://github.com/serge-sans-paille/pythran/issues/1995

We can still build scipy without pythran, so this should not be a major blocker.

Comment 2 Miro Hrončok 2022-06-06 11:33:35 UTC
This fixes the easy failure (KeyError: 'SO'): https://github.com/serge-sans-paille/pythran/pull/1996

For the "takes 2 positional arguments but 3 were given" problem, I am going to wait for upstream.

Comment 4 Miro Hrončok 2022-06-22 11:49:14 UTC
Closing this in bulk as it built with Python 3.11. If this needs to remain open for a followup, feel free to reopen, I won't close in bulk again.


Note You need to log in before you can comment on or make changes to this bug.