Karsten Hopp 9ff141
To: vim_dev@googlegroups.com
Karsten Hopp 9ff141
Subject: Patch 7.4.084
Karsten Hopp 9ff141
Fcc: outbox
Karsten Hopp 9ff141
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 9ff141
Mime-Version: 1.0
Karsten Hopp 9ff141
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 9ff141
Content-Transfer-Encoding: 8bit
Karsten Hopp 9ff141
------------
Karsten Hopp 9ff141
Karsten Hopp 9ff141
Patch 7.4.084
Karsten Hopp 9ff141
Problem:    Python: interrupt not being properly discarded. (Yggdroot Chen)
Karsten Hopp 9ff141
Solution:   Discard interrupt in VimTryEnd. (ZyX)
Karsten Hopp 9ff141
Files:      src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok,
Karsten Hopp 9ff141
            src/testdir/test87.in, src/testdir/test87.ok
Karsten Hopp 9ff141
Karsten Hopp 9ff141
Karsten Hopp 9ff141
*** ../vim-7.4.083/src/if_py_both.h	2013-11-04 00:34:47.000000000 +0100
Karsten Hopp 9ff141
--- src/if_py_both.h	2013-11-11 00:56:41.000000000 +0100
Karsten Hopp 9ff141
***************
Karsten Hopp 9ff141
*** 558,564 ****
Karsten Hopp 9ff141
      /* Keyboard interrupt should be preferred over anything else */
Karsten Hopp 9ff141
      if (got_int)
Karsten Hopp 9ff141
      {
Karsten Hopp 9ff141
! 	did_throw = got_int = FALSE;
Karsten Hopp 9ff141
  	PyErr_SetNone(PyExc_KeyboardInterrupt);
Karsten Hopp 9ff141
  	return -1;
Karsten Hopp 9ff141
      }
Karsten Hopp 9ff141
--- 558,568 ----
Karsten Hopp 9ff141
      /* Keyboard interrupt should be preferred over anything else */
Karsten Hopp 9ff141
      if (got_int)
Karsten Hopp 9ff141
      {
Karsten Hopp 9ff141
! 	if (current_exception != NULL)
Karsten Hopp 9ff141
! 	    discard_current_exception();
Karsten Hopp 9ff141
! 	else
Karsten Hopp 9ff141
! 	    need_rethrow = did_throw = FALSE;
Karsten Hopp 9ff141
! 	got_int = FALSE;
Karsten Hopp 9ff141
  	PyErr_SetNone(PyExc_KeyboardInterrupt);
Karsten Hopp 9ff141
  	return -1;
Karsten Hopp 9ff141
      }
Karsten Hopp 9ff141
***************
Karsten Hopp 9ff141
*** 567,573 ****
Karsten Hopp 9ff141
      /* Python exception is preferred over vim one; unlikely to occur though */
Karsten Hopp 9ff141
      else if (PyErr_Occurred())
Karsten Hopp 9ff141
      {
Karsten Hopp 9ff141
! 	did_throw = FALSE;
Karsten Hopp 9ff141
  	return -1;
Karsten Hopp 9ff141
      }
Karsten Hopp 9ff141
      /* Finally transform VimL exception to python one */
Karsten Hopp 9ff141
--- 571,580 ----
Karsten Hopp 9ff141
      /* Python exception is preferred over vim one; unlikely to occur though */
Karsten Hopp 9ff141
      else if (PyErr_Occurred())
Karsten Hopp 9ff141
      {
Karsten Hopp 9ff141
! 	if (current_exception != NULL)
Karsten Hopp 9ff141
! 	    discard_current_exception();
Karsten Hopp 9ff141
! 	else
Karsten Hopp 9ff141
! 	    need_rethrow = did_throw = FALSE;
Karsten Hopp 9ff141
  	return -1;
Karsten Hopp 9ff141
      }
Karsten Hopp 9ff141
      /* Finally transform VimL exception to python one */
Karsten Hopp 9ff141
*** ../vim-7.4.083/src/testdir/test86.in	2013-11-04 00:34:47.000000000 +0100
Karsten Hopp 9ff141
--- src/testdir/test86.in	2013-11-11 00:56:11.000000000 +0100
Karsten Hopp 9ff141
***************
Karsten Hopp 9ff141
*** 1281,1286 ****
Karsten Hopp 9ff141
--- 1281,1317 ----
Karsten Hopp 9ff141
  EOF
Karsten Hopp 9ff141
  :delfunction Exe
Karsten Hopp 9ff141
  :"
Karsten Hopp 9ff141
+ :" Regression: interrupting vim.command propagates to next vim.command
Karsten Hopp 9ff141
+ py << EOF
Karsten Hopp 9ff141
+ def test_keyboard_interrupt():
Karsten Hopp 9ff141
+     try:
Karsten Hopp 9ff141
+         vim.command('while 1 | endwhile')
Karsten Hopp 9ff141
+     except KeyboardInterrupt:
Karsten Hopp 9ff141
+         cb.append('Caught KeyboardInterrupt')
Karsten Hopp 9ff141
+     except Exception:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info))
Karsten Hopp 9ff141
+     else:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! No exception')
Karsten Hopp 9ff141
+     try:
Karsten Hopp 9ff141
+         vim.command('$ put =\'Running :put\'')
Karsten Hopp 9ff141
+     except KeyboardInterrupt:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! Caught KeyboardInterrupt')
Karsten Hopp 9ff141
+     except Exception:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! Caught exception: ' + repr(sys.exc_info))
Karsten Hopp 9ff141
+     else:
Karsten Hopp 9ff141
+         cb.append('No exception')
Karsten Hopp 9ff141
+ EOF
Karsten Hopp 9ff141
+ :debuggreedy
Karsten Hopp 9ff141
+ :call inputsave()
Karsten Hopp 9ff141
+ :call feedkeys("s\ns\ns\ns\nq\n")
Karsten Hopp 9ff141
+ :redir => output
Karsten Hopp 9ff141
+ :debug silent! py test_keyboard_interrupt()
Karsten Hopp 9ff141
+ :redir END
Karsten Hopp 9ff141
+ :0 debuggreedy
Karsten Hopp 9ff141
+ :silent $put =output
Karsten Hopp 9ff141
+ :unlet output
Karsten Hopp 9ff141
+ :py del test_keyboard_interrupt
Karsten Hopp 9ff141
+ :"
Karsten Hopp 9ff141
  :" Cleanup
Karsten Hopp 9ff141
  py << EOF
Karsten Hopp 9ff141
  del cb
Karsten Hopp 9ff141
*** ../vim-7.4.083/src/testdir/test86.ok	2013-11-04 00:34:47.000000000 +0100
Karsten Hopp 9ff141
--- src/testdir/test86.ok	2013-11-11 00:56:11.000000000 +0100
Karsten Hopp 9ff141
***************
Karsten Hopp 9ff141
*** 1198,1200 ****
Karsten Hopp 9ff141
--- 1198,1204 ----
Karsten Hopp 9ff141
  vim.eval("Exe('echoerr ''jkl''')"):error:('Vim(echoerr):jkl',)
Karsten Hopp 9ff141
  vim.eval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
Karsten Hopp 9ff141
  vim.bindeval("Exe('xxx_non_existent_command_xxx')"):error:('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)
Karsten Hopp 9ff141
+ Caught KeyboardInterrupt
Karsten Hopp 9ff141
+ Running :put
Karsten Hopp 9ff141
+ No exception
Karsten Hopp 9ff141
+ 
Karsten Hopp 9ff141
*** ../vim-7.4.083/src/testdir/test87.in	2013-11-04 00:34:47.000000000 +0100
Karsten Hopp 9ff141
--- src/testdir/test87.in	2013-11-11 00:56:11.000000000 +0100
Karsten Hopp 9ff141
***************
Karsten Hopp 9ff141
*** 1232,1237 ****
Karsten Hopp 9ff141
--- 1232,1268 ----
Karsten Hopp 9ff141
  EOF
Karsten Hopp 9ff141
  :delfunction Exe
Karsten Hopp 9ff141
  :"
Karsten Hopp 9ff141
+ :" Regression: interrupting vim.command propagates to next vim.command
Karsten Hopp 9ff141
+ py3 << EOF
Karsten Hopp 9ff141
+ def test_keyboard_interrupt():
Karsten Hopp 9ff141
+     try:
Karsten Hopp 9ff141
+         vim.command('while 1 | endwhile')
Karsten Hopp 9ff141
+     except KeyboardInterrupt:
Karsten Hopp 9ff141
+         cb.append('Caught KeyboardInterrupt')
Karsten Hopp 9ff141
+     except Exception as e:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! Caught exception: ' + repr(e))
Karsten Hopp 9ff141
+     else:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! No exception')
Karsten Hopp 9ff141
+     try:
Karsten Hopp 9ff141
+         vim.command('$ put =\'Running :put\'')
Karsten Hopp 9ff141
+     except KeyboardInterrupt:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! Caught KeyboardInterrupt')
Karsten Hopp 9ff141
+     except Exception as e:
Karsten Hopp 9ff141
+         cb.append('!!!!!!!! Caught exception: ' + repr(e))
Karsten Hopp 9ff141
+     else:
Karsten Hopp 9ff141
+         cb.append('No exception')
Karsten Hopp 9ff141
+ EOF
Karsten Hopp 9ff141
+ :debuggreedy
Karsten Hopp 9ff141
+ :call inputsave()
Karsten Hopp 9ff141
+ :call feedkeys("s\ns\ns\ns\nq\n")
Karsten Hopp 9ff141
+ :redir => output
Karsten Hopp 9ff141
+ :debug silent! py3 test_keyboard_interrupt()
Karsten Hopp 9ff141
+ :redir END
Karsten Hopp 9ff141
+ :0 debuggreedy
Karsten Hopp 9ff141
+ :silent $put =output
Karsten Hopp 9ff141
+ :unlet output
Karsten Hopp 9ff141
+ :py3 del test_keyboard_interrupt
Karsten Hopp 9ff141
+ :"
Karsten Hopp 9ff141
  :" Cleanup
Karsten Hopp 9ff141
  py3 << EOF
Karsten Hopp 9ff141
  del cb
Karsten Hopp 9ff141
*** ../vim-7.4.083/src/testdir/test87.ok	2013-11-04 00:34:47.000000000 +0100
Karsten Hopp 9ff141
--- src/testdir/test87.ok	2013-11-11 00:56:11.000000000 +0100
Karsten Hopp 9ff141
***************
Karsten Hopp 9ff141
*** 1187,1189 ****
Karsten Hopp 9ff141
--- 1187,1193 ----
Karsten Hopp 9ff141
  vim.eval("Exe('echoerr ''jkl''')"):(<class 'vim.error'>, error('Vim(echoerr):jkl',))
Karsten Hopp 9ff141
  vim.eval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
Karsten Hopp 9ff141
  vim.bindeval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',))
Karsten Hopp 9ff141
+ Caught KeyboardInterrupt
Karsten Hopp 9ff141
+ Running :put
Karsten Hopp 9ff141
+ No exception
Karsten Hopp 9ff141
+ 
Karsten Hopp 9ff141
*** ../vim-7.4.083/src/version.c	2013-11-09 05:30:18.000000000 +0100
Karsten Hopp 9ff141
--- src/version.c	2013-11-11 00:55:23.000000000 +0100
Karsten Hopp 9ff141
***************
Karsten Hopp 9ff141
*** 740,741 ****
Karsten Hopp 9ff141
--- 740,743 ----
Karsten Hopp 9ff141
  {   /* Add new patch number below this line */
Karsten Hopp 9ff141
+ /**/
Karsten Hopp 9ff141
+     84,
Karsten Hopp 9ff141
  /**/
Karsten Hopp 9ff141
Karsten Hopp 9ff141
-- 
Karsten Hopp 9ff141
Computers make very fast, very accurate, mistakes.
Karsten Hopp 9ff141
Karsten Hopp 9ff141
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 9ff141
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 9ff141
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 9ff141
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///