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

test_vim: Failure with Python 3.13 #571

Open
cryptomilk opened this issue Jun 14, 2024 · 1 comment
Open

test_vim: Failure with Python 3.13 #571

cryptomilk opened this issue Jun 14, 2024 · 1 comment

Comments

@cryptomilk
Copy link
Contributor

Hi,

I'm trying to fix pynvim with Python 3.13 which is in Fedora Rawhide (upcoming 41). The failure I get is:

=================================== FAILURES ===================================
_____________________________ test_python3_ex_eval _____________________________                                                                                                    
                                                                                          
vim = <pynvim.api.nvim.Nvim object at 0x7f2b5e068950>
                                                                                          
    def test_python3_ex_eval(vim: Nvim) -> None:                                
        assert '42' == vim.command_output('python3 =42')                                                                                                                            
        assert '42' == vim.command_output('python3 =   42     ')                
        assert '42' == vim.command_output('py3=    42     ')                                                                                                                        
        assert '42' == vim.command_output('py=42')
                                     
        # On syntax error or evaluation error, stacktrace information is printed
        # Note: the pynvim API command_output() throws an exception on error
        # because the Ex command :python will throw (wrapped with provider#python3#Call)
        with pytest.raises(NvimError) as excinfo:        
            vim.command('py3= 1/0')                                                       
>       assert textwrap.dedent('''\                                                       
            Traceback (most recent call last):                                                                                                                                      
              File "<string>", line 1, in <module>                                                                                                                                  
            ZeroDivisionError: division by zero
            ''').strip() in excinfo.value.args[0]                                                                                                                                   
E       assert 'Traceback (most recent call last):\n  File "<string>", line 1, in <module>\nZeroDivisionError: division by zero' in 'function provider#python3#Call, line 1: Vim(ret
urn):E5108: Error executing lua Vim:Error invoking \'python_execute\' on channel 3 (python3-script-host):\nTraceback (most recent call last):\n  File "<string>", line 1, in <module
>\n    import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; neovim.start_host()\n    ^^^\nZeroDivisionError: division by zero\nstack traceback:\n\t[C]: at 0x55bb
fd9c11af'                                                                                                                                                                           
E        +  where 'Traceback (most recent call last):\n  File "<string>", line 1, in <module>\nZeroDivisionError: division by zero' = <built-in method strip of str object at 0x7f2b
5e0752f0>()
E        +    where <built-in method strip of str object at 0x7f2b5e0752f0> = 'Traceback (most recent call last):\n  File "<string>", line 1, in <module>\nZeroDivisionError: divisi
on by zero\n'.strip
E        +      where 'Traceback (most recent call last):\n  File "<string>", line 1, in <module>\nZeroDivisionError: division by zero\n' = <function dedent at 0x7f2b5f868ae0>('   
     Traceback (most recent call last):\n          File "<string>", line 1, in <module>\n        ZeroDivisionError: division by zero\n        ')
E        +        where <function dedent at 0x7f2b5f868ae0> = textwrap.dedent

test/test_vim.py:233: AssertionError

The traceback looks different now.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; neovim.start_host()
    ^^^
ZeroDivisionError: division by zero

My current fix is for Fedora is:

Index: pynvim-0.5.0/test/test_vim.py
===================================================================
--- pynvim-0.5.0.orig/test/test_vim.py  2024-06-14 08:47:38.588584340 +0200
+++ pynvim-0.5.0/test/test_vim.py       2024-06-14 09:00:22.910093156 +0200
@@ -231,8 +231,6 @@ def test_python3_ex_eval(vim: Nvim) -> N
     with pytest.raises(NvimError) as excinfo:
         vim.command('py3= 1/0')
     assert textwrap.dedent('''\
-        Traceback (most recent call last):
-          File "<string>", line 1, in <module>
         ZeroDivisionError: division by zero
         ''').strip() in excinfo.value.args[0]
 
@@ -240,9 +238,6 @@ def test_python3_ex_eval(vim: Nvim) -> N
     with pytest.raises(NvimError) as excinfo:
         vim.command_output('python3 =print("nooo", raise_error())')
     assert textwrap.dedent('''\
-        Traceback (most recent call last):
-          File "<string>", line 1, in <module>
-          File "<string>", line 1, in raise_error
         RuntimeError: oops
         ''').strip() in excinfo.value.args[0]
     assert 'nooo' not in vim.command_output(':messages')

Not sure if this is how you would like to address this.

@justinmk
Copy link
Member

justinmk commented Jun 19, 2024

That seems fine to me. The stacktrace in all cases isn't particularly useful. @wookayin ?

If it's not much trouble, maybe also check for Traceback (most recent call last): but ignore the actual trace.

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

2 participants