]> granicus.if.org Git - vim/commitdiff
patch 8.1.1346: error for Python exception does not show useful info v8.1.1346
authorBram Moolenaar <Bram@vim.org>
Sat, 18 May 2019 13:02:25 +0000 (15:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 18 May 2019 13:02:25 +0000 (15:02 +0200)
Problem:    Error for Python exception does not show useful info.
Solution:   Show the last line instead of the first one. (Ben Jackson,
            closes #4381)

src/if_py_both.h
src/testdir/test86.ok
src/testdir/test87.ok
src/testdir/test_python2.vim
src/testdir/test_python3.vim
src/testdir/test_pyx2.vim
src/testdir/test_pyx3.vim
src/version.c

index 4e1a42a3cf606106e805ce3b4b183278e26a899e..cc0450c13b599798ccce569d42296fb41ada5ea7 100644 (file)
@@ -412,6 +412,8 @@ write_output(OutputObject *self, PyObject *string)
 
     Py_BEGIN_ALLOW_THREADS
     Python_Lock_Vim();
+    if (error)
+       emsg_severe = TRUE;
     writer((writefn)(error ? emsg : msg), (char_u *)str, len);
     Python_Release_Vim();
     Py_END_ALLOW_THREADS
index 24d3fd4bdeb8ed319253967234dc6b66858eaba9..6ad02e3723409fe752387bf9347127412413685b 100644 (file)
@@ -91,7 +91,7 @@ pyeval("None") = v:none
 0.0
 "\0":  Vim(let):E859:
 {"\0": 1}:     Vim(let):E859:
-undefined_name:        Vim(let):Trace
+undefined_name:        Vim(let):NameE
 vim:   Vim(let):E859:
 [1]
 [1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1]
index a7d4f64264b7966fad3d9ca29cb0c589a0514f5d..7ddea8f26e6b9de41643f39843ca31eaab5b1bf1 100644 (file)
@@ -91,7 +91,7 @@ py3eval("None") = v:none
 0.0
 "\0":  Vim(let):E859:
 {"\0": 1}:     Vim(let):E859:
-undefined_name:        Vim(let):Trace
+undefined_name:        Vim(let):NameE
 vim:   Vim(let):E859:
 [1]
 [1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1]
index 632f7a872fdec85b9da1a9c7c2663167fe627c7e..5703231ed745b4556268523f78801d72b1a0bcb3 100644 (file)
@@ -160,3 +160,11 @@ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
 
   bwipe!
 endfunction
+
+func Test_Catch_Exception_Message()
+  try
+    py raise RuntimeError( 'TEST' )
+  catch /.*/
+    call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
+  endtry
+endfunc
index 514661ee25a72257b99e1028d85ac6eba34d9a1c..aacc5a57595f0a209da07238fa2876810416e5a6 100644 (file)
@@ -160,3 +160,11 @@ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
 
   bwipe!
 endfunction
+
+func Test_Catch_Exception_Message()
+  try
+    py3 raise RuntimeError( 'TEST' )
+  catch /.*/
+    call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
+  endtry
+endfunc
index 50e57c3bfb7b35c6795e8607dbab6496d9fbabc4..baaf7fa3008af116d1beccc4b48f7ec830a2c278 100644 (file)
@@ -72,3 +72,11 @@ func Test_pyxfile()
     call assert_match(s:py3pattern, split(var)[0])
   endif
 endfunc
+
+func Test_Catch_Exception_Message()
+  try
+    pyx raise RuntimeError( 'TEST' )
+  catch /.*/
+    call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
+  endtry
+endfunc
index 64546b46886257b99a5de10af66e1e7b8b14d7f6..4b6057a8d5362fb72bed09c91c610ddb2805b512 100644 (file)
@@ -72,3 +72,11 @@ func Test_pyxfile()
     call assert_match(s:py2pattern, split(var)[0])
   endif
 endfunc
+
+func Test_Catch_Exception_Message()
+  try
+    pyx raise RuntimeError( 'TEST' )
+  catch /.*/
+    call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
+  endtry
+endfunc
index 519427655418e3bfd885b16af05fe79cd04642b4..fc1a5d56fb3bc8facee754fb28b6e29733058fc3 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1346,
 /**/
     1345,
 /**/