Skip to content

Commit 7f3a284

Browse files
committed
patch 8.1.1346: error for Python exception does not show useful info
Problem: Error for Python exception does not show useful info. Solution: Show the last line instead of the first one. (Ben Jackson, closes #4381)
1 parent 6349e94 commit 7f3a284

8 files changed

Lines changed: 38 additions & 2 deletions

File tree

src/if_py_both.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ write_output(OutputObject *self, PyObject *string)
412412

413413
Py_BEGIN_ALLOW_THREADS
414414
Python_Lock_Vim();
415+
if (error)
416+
emsg_severe = TRUE;
415417
writer((writefn)(error ? emsg : msg), (char_u *)str, len);
416418
Python_Release_Vim();
417419
Py_END_ALLOW_THREADS

src/testdir/test86.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pyeval("None") = v:none
9191
0.0
9292
"\0": Vim(let):E859:
9393
{"\0": 1}: Vim(let):E859:
94-
undefined_name: Vim(let):Trace
94+
undefined_name: Vim(let):NameE
9595
vim: Vim(let):E859:
9696
[1]
9797
[1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1]

src/testdir/test87.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ py3eval("None") = v:none
9191
0.0
9292
"\0": Vim(let):E859:
9393
{"\0": 1}: Vim(let):E859:
94-
undefined_name: Vim(let):Trace
94+
undefined_name: Vim(let):NameE
9595
vim: Vim(let):E859:
9696
[1]
9797
[1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1]

src/testdir/test_python2.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,11 @@ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
160160

161161
bwipe!
162162
endfunction
163+
164+
func Test_Catch_Exception_Message()
165+
try
166+
py raise RuntimeError( 'TEST' )
167+
catch /.*/
168+
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
169+
endtry
170+
endfunc

src/testdir/test_python3.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,11 @@ func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
160160

161161
bwipe!
162162
endfunction
163+
164+
func Test_Catch_Exception_Message()
165+
try
166+
py3 raise RuntimeError( 'TEST' )
167+
catch /.*/
168+
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
169+
endtry
170+
endfunc

src/testdir/test_pyx2.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,11 @@ func Test_pyxfile()
7272
call assert_match(s:py3pattern, split(var)[0])
7373
endif
7474
endfunc
75+
76+
func Test_Catch_Exception_Message()
77+
try
78+
pyx raise RuntimeError( 'TEST' )
79+
catch /.*/
80+
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
81+
endtry
82+
endfunc

src/testdir/test_pyx3.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,11 @@ func Test_pyxfile()
7272
call assert_match(s:py2pattern, split(var)[0])
7373
endif
7474
endfunc
75+
76+
func Test_Catch_Exception_Message()
77+
try
78+
pyx raise RuntimeError( 'TEST' )
79+
catch /.*/
80+
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
81+
endtry
82+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ static char *(features[]) =
767767

768768
static int included_patches[] =
769769
{ /* Add new patch number below this line */
770+
/**/
771+
1346,
770772
/**/
771773
1345,
772774
/**/

0 commit comments

Comments
 (0)