• Kirill Smelkov's avatar
    golang_str: tests: Adjust test_deepreplace_bytes for py3.12 · 0a797d0d
    Kirill Smelkov authored
    This test currently fails on py3.12 as follows:
    
            def test_deepreplace_bytes():
                def f(): pass
                g = lambda: None # non-picklable func
                with raises((pickle.PicklingError, AttributeError), match="Can't pickle "):
        >           pickle.dumps(g, pickle.HIGHEST_PROTOCOL)
        E           AttributeError: Can't get local object 'test_deepreplace_bytes.<locals>.<lambda>'
    
        golang/golang_str_test.py:2390: AttributeError
    
        During handling of the above exception, another exception occurred:
    
            def test_deepreplace_bytes():
                def f(): pass
                g = lambda: None # non-picklable func
        >       with raises((pickle.PicklingError, AttributeError), match="Can't pickle "):
        E       AssertionError: Regex pattern did not match.
        E        Regex: "Can't pickle "
        E        Input: "Can't get local object 'test_deepreplace_bytes.<locals>.<lambda>'"
    
    What happens here is that "cannot pickle lambda" error changed from
    py3.11 to py3.12:
    
        ---- 8< ---- (x.py)
        import pickle
    
        def fff():
            g = lambda: None
            pickle.dumps(g, pickle.HIGHEST_PROTOCOL)
    
        fff()
        ---- 8< ----
    
        kirr@deca:~$ python3.11 x.py
        ...
        AttributeError: Can't pickle local object 'fff.<locals>.<lambda>'
    
        kirr@deca:~$ python3.12 x.py
        ...
        AttributeError: Can't get local object 'fff.<locals>.<lambda>'
    
    -> Adjust the test to account for that.
    
    /cc @Daetalus
    /reviewed-by @jerome, @tomo
    /reviewed-on nexedi/pygolang!35
    0a797d0d
golang_str_test.py 117 KB