antocuni / pypytools

1 stars 2 forks source link

Test failure on Python 3.11 #4

Open fabaff opened 1 year ago

fabaff commented 1 year ago

With Python 3.11 there is a test failure. A fix would probably need to go on top of #2.

============================= test session starts ==============================
platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0
rootdir: /build/pypytools-0.6.2
collected 101 items                                                            

pypytools/gc/testing/test_custom.py .....s.                              [  6%]
pypytools/gc/testing/test_fakegc.py ...                                  [  9%]
pypytools/gc/testing/test_multihook.py ........                          [ 17%]
pypytools/gc/testing/test_uniform.py ..........                          [ 27%]
pypytools/pypylog/testing/test_model.py .....                            [ 32%]
pypytools/pypylog/testing/test_parse.py .x....x                          [ 39%]
pypytools/testing/test_cast.py .                                         [ 40%]
pypytools/testing/test_codegen.py ......................                 [ 62%]
pypytools/testing/test_fakecython.py ..                                  [ 64%]
pypytools/testing/test_micronumpy.py ...........................         [ 91%]
pypytools/testing/test_unroll.py ........                                [ 99%]
pypytools/testing/test_util.py F                                         [100%]

=================================== FAILURES ===================================
________________________________ test_clonefunc ________________________________

    def test_clonefunc():
        def foo(a, b):
            return a+b

>       foo2 = clonefunc(foo)

pypytools/testing/test_util.py:7: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

f = <function test_clonefunc.<locals>.foo at 0x7fff8df12480>

    def clonefunc(f):
        """Deep clone the given function to create a new one.

        By default, the PyPy JIT specializes the assembler based on f.__code__:
        clonefunc makes sure that you will get a new function with a **different**
        __code__, so that PyPy will produce independent assembler. This is useful
        e.g. for benchmarks and microbenchmarks, so you can make sure to compare
        apples to apples.

        Use it with caution: if abused, this might easily produce an explosion of
        produced assembler.
        """
        # first of all, we clone the code object
        co = f.__code__
        args = [co.co_argcount, co.co_nlocals, co.co_stacksize, co.co_flags, co.co_code,
                co.co_consts, co.co_names, co.co_varnames, co.co_filename, co.co_name,
                co.co_firstlineno, co.co_lnotab, co.co_freevars, co.co_cellvars]
        if PY3:
            args.insert(1, co.co_kwonlyargcount)
        if PY3 and PY3M >= 8:
            args.insert(1, co.co_posonlyargcount)
>       co2 = types.CodeType(*args)
E       TypeError: code() argument 13 must be str, not int

pypytools/util.py:28: TypeError
=========================== short test summary info ============================
FAILED pypytools/testing/test_util.py::test_clonefunc - TypeError: code() argument 13 must be str, not int
============== 1 failed, 97 passed, 1 skipped, 2 xfailed in 0.75s ==============