changeset 4409:7b789d337820 v7.3.953

updated for version 7.3.953 Problem: Python: string exceptions are deprecated. Solution: Make vim.error an Exception subclass. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Wed, 15 May 2013 16:04:40 +0200
parents 27b1cb7a9e12
children dc9e62f8cbb5
files src/if_python.c src/if_python3.c src/version.c
diffstat 3 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -149,6 +149,7 @@ struct PyMethodDef { Py_ssize_t a; };
 # define PyMem_Malloc dll_PyMem_Malloc
 # define PyDict_SetItemString dll_PyDict_SetItemString
 # define PyErr_BadArgument dll_PyErr_BadArgument
+# define PyErr_NewException dll_PyErr_NewException
 # define PyErr_Clear dll_PyErr_Clear
 # define PyErr_PrintEx dll_PyErr_PrintEx
 # define PyErr_NoMemory dll_PyErr_NoMemory
@@ -255,6 +256,7 @@ static int(*dll_PyMem_Free)(void *);
 static void* (*dll_PyMem_Malloc)(size_t);
 static int(*dll_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
 static int(*dll_PyErr_BadArgument)(void);
+static PyObject *(*dll_PyErr_NewException)(char *, PyObject *, PyObject *);
 static void(*dll_PyErr_Clear)(void);
 static void(*dll_PyErr_PrintEx)(int);
 static PyObject*(*dll_PyErr_NoMemory)(void);
@@ -391,6 +393,7 @@ static struct
     {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc},
     {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString},
     {"PyErr_BadArgument", (PYTHON_PROC*)&dll_PyErr_BadArgument},
+    {"PyErr_NewException", (PYTHON_PROC*)&dll_PyErr_NewException},
     {"PyErr_Clear", (PYTHON_PROC*)&dll_PyErr_Clear},
     {"PyErr_PrintEx", (PYTHON_PROC*)&dll_PyErr_PrintEx},
     {"PyErr_NoMemory", (PYTHON_PROC*)&dll_PyErr_NoMemory},
@@ -1304,7 +1307,7 @@ PythonMod_Init(void)
     mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION);
     dict = PyModule_GetDict(mod);
 
-    VimError = Py_BuildValue("s", "vim.error");
+    VimError = PyErr_NewException("vim.error", NULL, NULL);
 
     PyDict_SetItemString(dict, "error", VimError);
     PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferMap);
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -1606,8 +1606,8 @@ Py3Init_vim(void)
 	return NULL;
 
     VimError = PyErr_NewException("vim.error", NULL, NULL);
+
     Py_INCREF(VimError);
-
     PyModule_AddObject(mod, "error", VimError);
     Py_INCREF((PyObject *)(void *)&TheBufferMap);
     PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferMap);
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    953,
+/**/
     952,
 /**/
     951,