Karsten Hopp ae61a4
To: vim_dev@googlegroups.com
Karsten Hopp ae61a4
Subject: Patch 7.3.995
Karsten Hopp ae61a4
Fcc: outbox
Karsten Hopp ae61a4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ae61a4
Mime-Version: 1.0
Karsten Hopp ae61a4
Content-Type: text/plain; charset=UTF-8
Karsten Hopp ae61a4
Content-Transfer-Encoding: 8bit
Karsten Hopp ae61a4
------------
Karsten Hopp ae61a4
Karsten Hopp ae61a4
Patch 7.3.995
Karsten Hopp ae61a4
Problem:    Python: Module initialization is duplicated.
Karsten Hopp ae61a4
Solution:   Move to shared file. (ZyX)
Karsten Hopp ae61a4
Files:	    src/if_py_both.h, src/if_python3.c, src/if_python.c
Karsten Hopp ae61a4
Karsten Hopp ae61a4
Karsten Hopp ae61a4
*** ../vim-7.3.994/src/if_py_both.h	2013-05-21 19:01:51.000000000 +0200
Karsten Hopp ae61a4
--- src/if_py_both.h	2013-05-21 19:07:17.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 4181,4183 ****
Karsten Hopp ae61a4
--- 4181,4295 ----
Karsten Hopp ae61a4
      vimmodule.m_methods = VimMethods;
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ #define PYTYPE_READY(type) \
Karsten Hopp ae61a4
+     if (PyType_Ready(&type)) \
Karsten Hopp ae61a4
+ 	return -1;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+     static int
Karsten Hopp ae61a4
+ init_types()
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     PYTYPE_READY(IterType);
Karsten Hopp ae61a4
+     PYTYPE_READY(BufferType);
Karsten Hopp ae61a4
+     PYTYPE_READY(RangeType);
Karsten Hopp ae61a4
+     PYTYPE_READY(WindowType);
Karsten Hopp ae61a4
+     PYTYPE_READY(TabPageType);
Karsten Hopp ae61a4
+     PYTYPE_READY(BufMapType);
Karsten Hopp ae61a4
+     PYTYPE_READY(WinListType);
Karsten Hopp ae61a4
+     PYTYPE_READY(TabListType);
Karsten Hopp ae61a4
+     PYTYPE_READY(CurrentType);
Karsten Hopp ae61a4
+     PYTYPE_READY(DictionaryType);
Karsten Hopp ae61a4
+     PYTYPE_READY(ListType);
Karsten Hopp ae61a4
+     PYTYPE_READY(FunctionType);
Karsten Hopp ae61a4
+     PYTYPE_READY(OptionsType);
Karsten Hopp ae61a4
+     PYTYPE_READY(OutputType);
Karsten Hopp ae61a4
+     return 0;
Karsten Hopp ae61a4
+ }
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ static BufMapObject TheBufferMap =
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     PyObject_HEAD_INIT(&BufMapType)
Karsten Hopp ae61a4
+ };
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ static WinListObject TheWindowList =
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     PyObject_HEAD_INIT(&WinListType)
Karsten Hopp ae61a4
+     NULL
Karsten Hopp ae61a4
+ };
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ static CurrentObject TheCurrent =
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     PyObject_HEAD_INIT(&CurrentType)
Karsten Hopp ae61a4
+ };
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ static TabListObject TheTabPageList =
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     PyObject_HEAD_INIT(&TabListType)
Karsten Hopp ae61a4
+ };
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ static struct numeric_constant {
Karsten Hopp ae61a4
+     char	*name;
Karsten Hopp ae61a4
+     int		value;
Karsten Hopp ae61a4
+ } numeric_constants[] = {
Karsten Hopp ae61a4
+     {"VAR_LOCKED",	VAR_LOCKED},
Karsten Hopp ae61a4
+     {"VAR_FIXED",	VAR_FIXED},
Karsten Hopp ae61a4
+     {"VAR_SCOPE",	VAR_SCOPE},
Karsten Hopp ae61a4
+     {"VAR_DEF_SCOPE",	VAR_DEF_SCOPE},
Karsten Hopp ae61a4
+ };
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ static struct object_constant {
Karsten Hopp ae61a4
+     char	*name;
Karsten Hopp ae61a4
+     PyObject	*value;
Karsten Hopp ae61a4
+ } object_constants[] = {
Karsten Hopp ae61a4
+     {"buffers",  (PyObject *)(void *)&TheBufferMap},
Karsten Hopp ae61a4
+     {"windows",  (PyObject *)(void *)&TheWindowList},
Karsten Hopp ae61a4
+     {"tabpages", (PyObject *)(void *)&TheTabPageList},
Karsten Hopp ae61a4
+     {"current",  (PyObject *)(void *)&TheCurrent},
Karsten Hopp ae61a4
+ };
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ typedef int (*object_adder)(PyObject *, const char *, PyObject *);
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ #define ADD_OBJECT(m, name, obj) \
Karsten Hopp ae61a4
+     if (add_object(m, name, obj)) \
Karsten Hopp ae61a4
+ 	return -1;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ #define ADD_CHECKED_OBJECT(m, name, obj) \
Karsten Hopp ae61a4
+     { \
Karsten Hopp ae61a4
+ 	PyObject	*value = obj; \
Karsten Hopp ae61a4
+ 	if (!value) \
Karsten Hopp ae61a4
+ 	    return -1; \
Karsten Hopp ae61a4
+ 	ADD_OBJECT(m, name, value); \
Karsten Hopp ae61a4
+     }
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+     static int
Karsten Hopp ae61a4
+ populate_module(PyObject *m, object_adder add_object)
Karsten Hopp ae61a4
+ {
Karsten Hopp ae61a4
+     int i;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+     for (i = 0; i < (int)(sizeof(numeric_constants)
Karsten Hopp ae61a4
+ 					   / sizeof(struct numeric_constant));
Karsten Hopp ae61a4
+ 	    ++i)
Karsten Hopp ae61a4
+ 	ADD_CHECKED_OBJECT(m, numeric_constants[i].name,
Karsten Hopp ae61a4
+ 		PyInt_FromLong(numeric_constants[i].value));
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+     for (i = 0; i < (int)(sizeof(object_constants)
Karsten Hopp ae61a4
+ 					    / sizeof(struct object_constant));
Karsten Hopp ae61a4
+ 	    ++i)
Karsten Hopp ae61a4
+     {
Karsten Hopp ae61a4
+ 	PyObject	*value;
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+ 	value = object_constants[i].value;
Karsten Hopp ae61a4
+ 	Py_INCREF(value);
Karsten Hopp ae61a4
+ 	ADD_OBJECT(m, object_constants[i].name, value);
Karsten Hopp ae61a4
+     }
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+     if (!(VimError = PyErr_NewException("vim.error", NULL, NULL)))
Karsten Hopp ae61a4
+ 	return -1;
Karsten Hopp ae61a4
+     ADD_OBJECT(m, "error", VimError);
Karsten Hopp ae61a4
+ 
Karsten Hopp ae61a4
+     ADD_CHECKED_OBJECT(m, "vars",  DictionaryNew(&globvardict));
Karsten Hopp ae61a4
+     ADD_CHECKED_OBJECT(m, "vvars", DictionaryNew(&vimvardict));
Karsten Hopp ae61a4
+     ADD_CHECKED_OBJECT(m, "options",
Karsten Hopp ae61a4
+ 	    OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL));
Karsten Hopp ae61a4
+     return 0;
Karsten Hopp ae61a4
+ }
Karsten Hopp ae61a4
*** ../vim-7.3.994/src/if_python3.c	2013-05-21 19:01:51.000000000 +0200
Karsten Hopp ae61a4
--- src/if_python3.c	2013-05-21 19:07:40.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 700,706 ****
Karsten Hopp ae61a4
   * Internal function prototypes.
Karsten Hopp ae61a4
   */
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
- static int PythonIO_Init(void);
Karsten Hopp ae61a4
  static PyObject *Py3Init_vim(void);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  /******************************************************
Karsten Hopp ae61a4
--- 700,705 ----
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 780,786 ****
Karsten Hopp ae61a4
  	get_py3_exceptions();
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PythonIO_Init())
Karsten Hopp ae61a4
  	    goto fail;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	globals = PyModule_GetDict(PyImport_AddModule("__main__"));
Karsten Hopp ae61a4
--- 779,785 ----
Karsten Hopp ae61a4
  	get_py3_exceptions();
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PythonIO_Init_io())
Karsten Hopp ae61a4
  	    goto fail;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	globals = PyModule_GetDict(PyImport_AddModule("__main__"));
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 811,817 ****
Karsten Hopp ae61a4
  fail:
Karsten Hopp ae61a4
      /* We call PythonIO_Flush() here to print any Python errors.
Karsten Hopp ae61a4
       * This is OK, as it is possible to call this function even
Karsten Hopp ae61a4
!      * if PythonIO_Init() has not completed successfully (it will
Karsten Hopp ae61a4
       * not do anything in this case).
Karsten Hopp ae61a4
       */
Karsten Hopp ae61a4
      PythonIO_Flush();
Karsten Hopp ae61a4
--- 810,816 ----
Karsten Hopp ae61a4
  fail:
Karsten Hopp ae61a4
      /* We call PythonIO_Flush() here to print any Python errors.
Karsten Hopp ae61a4
       * This is OK, as it is possible to call this function even
Karsten Hopp ae61a4
!      * if PythonIO_Init_io() has not completed successfully (it will
Karsten Hopp ae61a4
       * not do anything in this case).
Karsten Hopp ae61a4
       */
Karsten Hopp ae61a4
      PythonIO_Flush();
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1008,1022 ****
Karsten Hopp ae61a4
      return OutputSetattr((OutputObject *)(self), name, val);
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
- /***************/
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
-     static int
Karsten Hopp ae61a4
- PythonIO_Init(void)
Karsten Hopp ae61a4
- {
Karsten Hopp ae61a4
-     PyType_Ready(&OutputType);
Karsten Hopp ae61a4
-     return PythonIO_Init_io();
Karsten Hopp ae61a4
- }
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
  /******************************************************
Karsten Hopp ae61a4
   * 3. Implementation of the Vim module for Python
Karsten Hopp ae61a4
   */
Karsten Hopp ae61a4
--- 1007,1012 ----
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1538,1585 ****
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
- static BufMapObject TheBufferMap =
Karsten Hopp ae61a4
- {
Karsten Hopp ae61a4
-     PyObject_HEAD_INIT(&BufMapType)
Karsten Hopp ae61a4
- };
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
- static WinListObject TheWindowList =
Karsten Hopp ae61a4
- {
Karsten Hopp ae61a4
-     PyObject_HEAD_INIT(&WinListType)
Karsten Hopp ae61a4
-     NULL
Karsten Hopp ae61a4
- };
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
- static CurrentObject TheCurrent =
Karsten Hopp ae61a4
- {
Karsten Hopp ae61a4
-     PyObject_HEAD_INIT(&CurrentType)
Karsten Hopp ae61a4
- };
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
- static TabListObject TheTabPageList =
Karsten Hopp ae61a4
- {
Karsten Hopp ae61a4
-     PyObject_HEAD_INIT(&TabListType)
Karsten Hopp ae61a4
- };
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
      static PyObject *
Karsten Hopp ae61a4
  Py3Init_vim(void)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
      PyObject *mod;
Karsten Hopp ae61a4
!     PyObject *tmp;
Karsten Hopp ae61a4
      /* The special value is removed from sys.path in Python3_Init(). */
Karsten Hopp ae61a4
      static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     PyType_Ready(&IterType);
Karsten Hopp ae61a4
!     PyType_Ready(&BufferType);
Karsten Hopp ae61a4
!     PyType_Ready(&RangeType);
Karsten Hopp ae61a4
!     PyType_Ready(&WindowType);
Karsten Hopp ae61a4
!     PyType_Ready(&TabPageType);
Karsten Hopp ae61a4
!     PyType_Ready(&BufMapType);
Karsten Hopp ae61a4
!     PyType_Ready(&WinListType);
Karsten Hopp ae61a4
!     PyType_Ready(&TabListType);
Karsten Hopp ae61a4
!     PyType_Ready(&CurrentType);
Karsten Hopp ae61a4
!     PyType_Ready(&DictionaryType);
Karsten Hopp ae61a4
!     PyType_Ready(&ListType);
Karsten Hopp ae61a4
!     PyType_Ready(&FunctionType);
Karsten Hopp ae61a4
!     PyType_Ready(&OptionsType);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      /* Set sys.argv[] to avoid a crash in warn(). */
Karsten Hopp ae61a4
      PySys_SetArgv(1, argv);
Karsten Hopp ae61a4
--- 1528,1543 ----
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      static PyObject *
Karsten Hopp ae61a4
  Py3Init_vim(void)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
      PyObject *mod;
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
      /* The special value is removed from sys.path in Python3_Init(). */
Karsten Hopp ae61a4
      static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     if (init_types())
Karsten Hopp ae61a4
! 	return NULL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      /* Set sys.argv[] to avoid a crash in warn(). */
Karsten Hopp ae61a4
      PySys_SetArgv(1, argv);
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1588,1622 ****
Karsten Hopp ae61a4
      if (mod == NULL)
Karsten Hopp ae61a4
  	return NULL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     VimError = PyErr_NewException("vim.error", NULL, NULL);
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
!     Py_INCREF(VimError);
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "error", VimError);
Karsten Hopp ae61a4
!     Py_INCREF((PyObject *)(void *)&TheBufferMap);
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "buffers", (PyObject *)(void *)&TheBufferMap);
Karsten Hopp ae61a4
!     Py_INCREF((PyObject *)(void *)&TheCurrent);
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "current", (PyObject *)(void *)&TheCurrent);
Karsten Hopp ae61a4
!     Py_INCREF((PyObject *)(void *)&TheWindowList);
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "windows", (PyObject *)(void *)&TheWindowList);
Karsten Hopp ae61a4
!     Py_INCREF((PyObject *)(void *)&TheTabPageList);
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "tabpages", (PyObject *)(void *)&TheTabPageList);
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "vars", DictionaryNew(&globvardict));
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "vvars", DictionaryNew(&vimvardict));
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, "options",
Karsten Hopp ae61a4
! 	    OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL));
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
! #define ADD_INT_CONSTANT(name, value) \
Karsten Hopp ae61a4
!     tmp = PyLong_FromLong(value); \
Karsten Hopp ae61a4
!     Py_INCREF(tmp); \
Karsten Hopp ae61a4
!     PyModule_AddObject(mod, name, tmp)
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
!     ADD_INT_CONSTANT("VAR_LOCKED",     VAR_LOCKED);
Karsten Hopp ae61a4
!     ADD_INT_CONSTANT("VAR_FIXED",      VAR_FIXED);
Karsten Hopp ae61a4
!     ADD_INT_CONSTANT("VAR_SCOPE",      VAR_SCOPE);
Karsten Hopp ae61a4
!     ADD_INT_CONSTANT("VAR_DEF_SCOPE",  VAR_DEF_SCOPE);
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
!     if (PyErr_Occurred())
Karsten Hopp ae61a4
  	return NULL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      return mod;
Karsten Hopp ae61a4
--- 1546,1552 ----
Karsten Hopp ae61a4
      if (mod == NULL)
Karsten Hopp ae61a4
  	return NULL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     if (populate_module(mod, PyModule_AddObject))
Karsten Hopp ae61a4
  	return NULL;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      return mod;
Karsten Hopp ae61a4
*** ../vim-7.3.994/src/if_python.c	2013-05-21 18:30:29.000000000 +0200
Karsten Hopp ae61a4
--- src/if_python.c	2013-05-21 19:07:26.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 657,663 ****
Karsten Hopp ae61a4
   * Internal function prototypes.
Karsten Hopp ae61a4
   */
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
- static int PythonIO_Init(void);
Karsten Hopp ae61a4
  static int PythonMod_Init(void);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
--- 657,662 ----
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 772,778 ****
Karsten Hopp ae61a4
  	get_exceptions();
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PythonIO_Init())
Karsten Hopp ae61a4
  	    goto fail;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (PythonMod_Init())
Karsten Hopp ae61a4
--- 771,777 ----
Karsten Hopp ae61a4
  	get_exceptions();
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! 	if (PythonIO_Init_io())
Karsten Hopp ae61a4
  	    goto fail;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  	if (PythonMod_Init())
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 806,812 ****
Karsten Hopp ae61a4
  fail:
Karsten Hopp ae61a4
      /* We call PythonIO_Flush() here to print any Python errors.
Karsten Hopp ae61a4
       * This is OK, as it is possible to call this function even
Karsten Hopp ae61a4
!      * if PythonIO_Init() has not completed successfully (it will
Karsten Hopp ae61a4
       * not do anything in this case).
Karsten Hopp ae61a4
       */
Karsten Hopp ae61a4
      PythonIO_Flush();
Karsten Hopp ae61a4
--- 805,811 ----
Karsten Hopp ae61a4
  fail:
Karsten Hopp ae61a4
      /* We call PythonIO_Flush() here to print any Python errors.
Karsten Hopp ae61a4
       * This is OK, as it is possible to call this function even
Karsten Hopp ae61a4
!      * if PythonIO_Init_io() has not completed successfully (it will
Karsten Hopp ae61a4
       * not do anything in this case).
Karsten Hopp ae61a4
       */
Karsten Hopp ae61a4
      PythonIO_Flush();
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 993,1009 ****
Karsten Hopp ae61a4
      return Py_FindMethod(OutputMethods, self, name);
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
- /***************/
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
-     static int
Karsten Hopp ae61a4
- PythonIO_Init(void)
Karsten Hopp ae61a4
- {
Karsten Hopp ae61a4
-     /* Fixups... */
Karsten Hopp ae61a4
-     PyType_Ready(&OutputType);
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
-     return PythonIO_Init_io();
Karsten Hopp ae61a4
- }
Karsten Hopp ae61a4
- 
Karsten Hopp ae61a4
  /******************************************************
Karsten Hopp ae61a4
   * 3. Implementation of the Vim module for Python
Karsten Hopp ae61a4
   */
Karsten Hopp ae61a4
--- 992,997 ----
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1242,1288 ****
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
! static BufMapObject TheBufferMap =
Karsten Hopp ae61a4
! {
Karsten Hopp ae61a4
!     PyObject_HEAD_INIT(&BufMapType)
Karsten Hopp ae61a4
! };
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
! static WinListObject TheWindowList =
Karsten Hopp ae61a4
! {
Karsten Hopp ae61a4
!     PyObject_HEAD_INIT(&WinListType)
Karsten Hopp ae61a4
!     NULL
Karsten Hopp ae61a4
! };
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
! static CurrentObject TheCurrent =
Karsten Hopp ae61a4
! {
Karsten Hopp ae61a4
!     PyObject_HEAD_INIT(&CurrentType)
Karsten Hopp ae61a4
! };
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
! static TabListObject TheTabPageList =
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
!     PyObject_HEAD_INIT(&TabListType)
Karsten Hopp ae61a4
! };
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      static int
Karsten Hopp ae61a4
  PythonMod_Init(void)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
      PyObject *mod;
Karsten Hopp ae61a4
      PyObject *dict;
Karsten Hopp ae61a4
!     PyObject *tmp;
Karsten Hopp ae61a4
      /* The special value is removed from sys.path in Python_Init(). */
Karsten Hopp ae61a4
      static char *(argv[2]) = {"/must>not&exist/foo", NULL};
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     /* Fixups... */
Karsten Hopp ae61a4
!     PyType_Ready(&IterType);
Karsten Hopp ae61a4
!     PyType_Ready(&BufferType);
Karsten Hopp ae61a4
!     PyType_Ready(&RangeType);
Karsten Hopp ae61a4
!     PyType_Ready(&WindowType);
Karsten Hopp ae61a4
!     PyType_Ready(&TabPageType);
Karsten Hopp ae61a4
!     PyType_Ready(&BufMapType);
Karsten Hopp ae61a4
!     PyType_Ready(&WinListType);
Karsten Hopp ae61a4
!     PyType_Ready(&TabListType);
Karsten Hopp ae61a4
!     PyType_Ready(&CurrentType);
Karsten Hopp ae61a4
!     PyType_Ready(&OptionsType);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      /* Set sys.argv[] to avoid a crash in warn(). */
Karsten Hopp ae61a4
      PySys_SetArgv(1, argv);
Karsten Hopp ae61a4
--- 1230,1255 ----
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  #endif
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     static int
Karsten Hopp ae61a4
! add_object(PyObject *dict, const char *name, PyObject *object)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
!     if (PyDict_SetItemString(dict, (char *) name, object))
Karsten Hopp ae61a4
! 	return -1;
Karsten Hopp ae61a4
!     Py_DECREF(object);
Karsten Hopp ae61a4
!     return 0;
Karsten Hopp ae61a4
! }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      static int
Karsten Hopp ae61a4
  PythonMod_Init(void)
Karsten Hopp ae61a4
  {
Karsten Hopp ae61a4
      PyObject *mod;
Karsten Hopp ae61a4
      PyObject *dict;
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
      /* The special value is removed from sys.path in Python_Init(). */
Karsten Hopp ae61a4
      static char *(argv[2]) = {"/must>not&exist/foo", NULL};
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     if (init_types())
Karsten Hopp ae61a4
! 	return -1;
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
      /* Set sys.argv[] to avoid a crash in warn(). */
Karsten Hopp ae61a4
      PySys_SetArgv(1, argv);
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 1290,1320 ****
Karsten Hopp ae61a4
      mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION);
Karsten Hopp ae61a4
      dict = PyModule_GetDict(mod);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     VimError = PyErr_NewException("vim.error", NULL, NULL);
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "error", VimError);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "buffers", (PyObject *)(void *)&TheBufferMap);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "current", (PyObject *)(void *)&TheCurrent);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "windows", (PyObject *)(void *)&TheWindowList);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "tabpages", (PyObject *)(void *)&TheTabPageList);
Karsten Hopp ae61a4
!     tmp = DictionaryNew(&globvardict);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "vars",    tmp);
Karsten Hopp ae61a4
!     Py_DECREF(tmp);
Karsten Hopp ae61a4
!     tmp = DictionaryNew(&vimvardict);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "vvars",   tmp);
Karsten Hopp ae61a4
!     Py_DECREF(tmp);
Karsten Hopp ae61a4
!     tmp = OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "options", tmp);
Karsten Hopp ae61a4
!     Py_DECREF(tmp);
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "VAR_LOCKED",    PyInt_FromLong(VAR_LOCKED));
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "VAR_FIXED",     PyInt_FromLong(VAR_FIXED));
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "VAR_SCOPE",     PyInt_FromLong(VAR_SCOPE));
Karsten Hopp ae61a4
!     PyDict_SetItemString(dict, "VAR_DEF_SCOPE", PyInt_FromLong(VAR_DEF_SCOPE));
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
!     if (PyErr_Occurred())
Karsten Hopp ae61a4
! 	return -1;
Karsten Hopp ae61a4
! 
Karsten Hopp ae61a4
!     return 0;
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  /*************************************************************************
Karsten Hopp ae61a4
--- 1257,1263 ----
Karsten Hopp ae61a4
      mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION);
Karsten Hopp ae61a4
      dict = PyModule_GetDict(mod);
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
!     return populate_module(dict, add_object);
Karsten Hopp ae61a4
  }
Karsten Hopp ae61a4
  
Karsten Hopp ae61a4
  /*************************************************************************
Karsten Hopp ae61a4
*** ../vim-7.3.994/src/version.c	2013-05-21 19:01:51.000000000 +0200
Karsten Hopp ae61a4
--- src/version.c	2013-05-21 19:06:22.000000000 +0200
Karsten Hopp ae61a4
***************
Karsten Hopp ae61a4
*** 730,731 ****
Karsten Hopp ae61a4
--- 730,733 ----
Karsten Hopp ae61a4
  {   /* Add new patch number below this line */
Karsten Hopp ae61a4
+ /**/
Karsten Hopp ae61a4
+     995,
Karsten Hopp ae61a4
  /**/
Karsten Hopp ae61a4
Karsten Hopp ae61a4
-- 
Karsten Hopp ae61a4
System administrators are just like women: You can't live with them and you
Karsten Hopp ae61a4
can't live without them.
Karsten Hopp ae61a4
Karsten Hopp ae61a4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ae61a4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ae61a4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp ae61a4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///