Skip to content

Commit 7d889b5

Browse files
committed
updated for version 7.4.084
Problem: Python: interrupt not being properly discarded. (Yggdroot Chen) Solution: Discard interrupt in VimTryEnd. (ZyX)
1 parent d872f26 commit 7d889b5

File tree

6 files changed

+81
-2
lines changed

6 files changed

+81
-2
lines changed

src/if_py_both.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,11 @@ VimTryEnd(void)
558558
/* Keyboard interrupt should be preferred over anything else */
559559
if (got_int)
560560
{
561-
did_throw = got_int = FALSE;
561+
if (current_exception != NULL)
562+
discard_current_exception();
563+
else
564+
need_rethrow = did_throw = FALSE;
565+
got_int = FALSE;
562566
PyErr_SetNone(PyExc_KeyboardInterrupt);
563567
return -1;
564568
}
@@ -567,7 +571,10 @@ VimTryEnd(void)
567571
/* Python exception is preferred over vim one; unlikely to occur though */
568572
else if (PyErr_Occurred())
569573
{
570-
did_throw = FALSE;
574+
if (current_exception != NULL)
575+
discard_current_exception();
576+
else
577+
need_rethrow = did_throw = FALSE;
571578
return -1;
572579
}
573580
/* Finally transform VimL exception to python one */

src/testdir/test86.in

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,37 @@ del Exe
12811281
EOF
12821282
:delfunction Exe
12831283
:"
1284+
:" Regression: interrupting vim.command propagates to next vim.command
1285+
py << EOF
1286+
def test_keyboard_interrupt():
1287+
try:
1288+
vim.command('while 1 | endwhile')
1289+
except KeyboardInterrupt:
1290+
cb.append('Caught KeyboardInterrupt')
1291+
except Exception:
1292+
cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info))
1293+
else:
1294+
cb.append('!!!!!!!! No exception')
1295+
try:
1296+
vim.command('$ put =\'Running :put\'')
1297+
except KeyboardInterrupt:
1298+
cb.append('!!!!!!!! Caught KeyboardInterrupt')
1299+
except Exception:
1300+
cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info))
1301+
else:
1302+
cb.append('No exception')
1303+
EOF
1304+
:debuggreedy
1305+
:call inputsave()
1306+
:call feedkeys("s\ns\ns\ns\nq\n")
1307+
:redir => output
1308+
:debug silent! py test_keyboard_interrupt()
1309+
:redir END
1310+
:0 debuggreedy
1311+
:silent $put =output
1312+
:unlet output
1313+
:py del test_keyboard_interrupt
1314+
:"
12841315
:" Cleanup
12851316
py << EOF
12861317
del cb

src/testdir/test86.ok

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,3 +1198,7 @@ vim.eval("Exe('throw ''ghi''')"):error:('ghi',)
11981198
vim.eval("Exe('echoerr ''jkl''')"):error:('Vim(echoerr):jkl',)
11991199
vim.eval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
12001200
vim.bindeval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
1201+
Caught KeyboardInterrupt
1202+
Running :put
1203+
No exception
1204+

src/testdir/test87.in

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,37 @@ del Exe
12321232
EOF
12331233
:delfunction Exe
12341234
:"
1235+
:" Regression: interrupting vim.command propagates to next vim.command
1236+
py3 << EOF
1237+
def test_keyboard_interrupt():
1238+
try:
1239+
vim.command('while 1 | endwhile')
1240+
except KeyboardInterrupt:
1241+
cb.append('Caught KeyboardInterrupt')
1242+
except Exception as e:
1243+
cb.append('!!!!!!!! Caught exception: ' + repr(e))
1244+
else:
1245+
cb.append('!!!!!!!! No exception')
1246+
try:
1247+
vim.command('$ put =\'Running :put\'')
1248+
except KeyboardInterrupt:
1249+
cb.append('!!!!!!!! Caught KeyboardInterrupt')
1250+
except Exception as e:
1251+
cb.append('!!!!!!!! Caught exception: ' + repr(e))
1252+
else:
1253+
cb.append('No exception')
1254+
EOF
1255+
:debuggreedy
1256+
:call inputsave()
1257+
:call feedkeys("s\ns\ns\ns\nq\n")
1258+
:redir => output
1259+
:debug silent! py3 test_keyboard_interrupt()
1260+
:redir END
1261+
:0 debuggreedy
1262+
:silent $put =output
1263+
:unlet output
1264+
:py3 del test_keyboard_interrupt
1265+
:"
12351266
:" Cleanup
12361267
py3 << EOF
12371268
del cb

src/testdir/test87.ok

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,3 +1187,7 @@ vim.eval("Exe('throw ''ghi''')"):(<class 'vim.error'>, error('ghi',))
11871187
vim.eval("Exe('echoerr ''jkl''')"):(<class 'vim.error'>, error('Vim(echoerr):jkl',))
11881188
vim.eval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
11891189
vim.bindeval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
1190+
Caught KeyboardInterrupt
1191+
Running :put
1192+
No exception
1193+

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
84,
741743
/**/
742744
83,
743745
/**/

0 commit comments

Comments
 (0)