diff src/if_py_both.h @ 4513:cadb57fbb781 v7.3.1004

updated for version 7.3.1004 Problem: No error when option could not be set. Solution: Report an error. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Tue, 21 May 2013 22:38:18 +0200
parents ce94a870b59b
children 57393dc4b811
line wrap: on
line diff
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -1521,6 +1521,25 @@ OptionsItem(OptionsObject *self, PyObjec
 }
 
     static int
+set_option_value_err(key, numval, stringval, opt_flags)
+    char_u	*key;
+    int		numval;
+    char_u	*stringval;
+    int		opt_flags;
+{
+    char_u	*errmsg;
+
+    if ((errmsg = set_option_value(key, numval, stringval, opt_flags)))
+    {
+	if (VimTryEnd())
+	    return FAIL;
+	PyErr_SetVim((char *)errmsg);
+	return FAIL;
+    }
+    return OK;
+}
+
+    static int
 set_option_value_for(key, numval, stringval, opt_flags, opt_type, from)
     char_u	*key;
     int		numval;
@@ -1532,6 +1551,7 @@ set_option_value_for(key, numval, string
     win_T	*save_curwin = NULL;
     tabpage_T	*save_curtab = NULL;
     buf_T	*save_curbuf = NULL;
+    int		r = 0;
 
     VimTryStart();
     switch (opt_type)
@@ -1545,16 +1565,22 @@ set_option_value_for(key, numval, string
 		PyErr_SetVim("Problem while switching windows.");
 		return -1;
 	    }
-	    set_option_value(key, numval, stringval, opt_flags);
+	    r = set_option_value_err(key, numval, stringval, opt_flags);
 	    restore_win(save_curwin, save_curtab);
+	    if (r == FAIL)
+		return -1;
 	    break;
 	case SREQ_BUF:
 	    switch_buffer(&save_curbuf, (buf_T *)from);
-	    set_option_value(key, numval, stringval, opt_flags);
+	    r = set_option_value_err(key, numval, stringval, opt_flags);
 	    restore_buffer(save_curbuf);
+	    if (r == FAIL)
+		return -1;
 	    break;
 	case SREQ_GLOBAL:
-	    set_option_value(key, numval, stringval, opt_flags);
+	    r = set_option_value_err(key, numval, stringval, opt_flags);
+	    if (r == FAIL)
+		return -1;
 	    break;
     }
     return VimTryEnd();
@@ -1611,6 +1637,7 @@ OptionsAssItem(OptionsObject *self, PyOb
     if (flags & SOPT_BOOL)
     {
 	int	istrue = PyObject_IsTrue(valObject);
+
 	if (istrue == -1)
 	    return -1;
 	r = set_option_value_for(key, istrue, NULL,