Karsten Hopp 999485
To: vim_dev@googlegroups.com
Karsten Hopp 999485
Subject: Patch 7.3.688
Karsten Hopp 999485
Fcc: outbox
Karsten Hopp 999485
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 999485
Mime-Version: 1.0
Karsten Hopp 999485
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 999485
Content-Transfer-Encoding: 8bit
Karsten Hopp 999485
------------
Karsten Hopp 999485
Karsten Hopp 999485
Patch 7.3.688
Karsten Hopp 999485
Problem:    Python 3.3 is not supported.
Karsten Hopp 999485
Solution:   Add Python 3.3 support (Ken Takata)
Karsten Hopp 999485
Files:      src/if_python3.c
Karsten Hopp 999485
Karsten Hopp 999485
Karsten Hopp 999485
*** ../vim-7.3.687/src/if_python3.c	2012-09-21 14:00:05.000000000 +0200
Karsten Hopp 999485
--- src/if_python3.c	2012-10-14 03:19:53.000000000 +0200
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 174,180 ****
Karsten Hopp 999485
  # define _PyObject_NextNotImplemented (*py3__PyObject_NextNotImplemented)
Karsten Hopp 999485
  # define PyModule_AddObject py3_PyModule_AddObject
Karsten Hopp 999485
  # define PyImport_AppendInittab py3_PyImport_AppendInittab
Karsten Hopp 999485
! # define _PyUnicode_AsString py3__PyUnicode_AsString
Karsten Hopp 999485
  # undef PyUnicode_AsEncodedString
Karsten Hopp 999485
  # define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
Karsten Hopp 999485
  # undef PyBytes_AsString
Karsten Hopp 999485
--- 174,185 ----
Karsten Hopp 999485
  # define _PyObject_NextNotImplemented (*py3__PyObject_NextNotImplemented)
Karsten Hopp 999485
  # define PyModule_AddObject py3_PyModule_AddObject
Karsten Hopp 999485
  # define PyImport_AppendInittab py3_PyImport_AppendInittab
Karsten Hopp 999485
! # if PY_VERSION_HEX >= 0x030300f0
Karsten Hopp 999485
! #  undef _PyUnicode_AsString
Karsten Hopp 999485
! #  define _PyUnicode_AsString py3_PyUnicode_AsUTF8String
Karsten Hopp 999485
! # else
Karsten Hopp 999485
! #  define _PyUnicode_AsString py3__PyUnicode_AsString
Karsten Hopp 999485
! # endif
Karsten Hopp 999485
  # undef PyUnicode_AsEncodedString
Karsten Hopp 999485
  # define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
Karsten Hopp 999485
  # undef PyBytes_AsString
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 281,287 ****
Karsten Hopp 999485
--- 286,296 ----
Karsten Hopp 999485
  static PyObject* py3__Py_TrueStruct;
Karsten Hopp 999485
  static int (*py3_PyModule_AddObject)(PyObject *m, const char *name, PyObject *o);
Karsten Hopp 999485
  static int (*py3_PyImport_AppendInittab)(const char *name, PyObject* (*initfunc)(void));
Karsten Hopp 999485
+ #if PY_VERSION_HEX >= 0x030300f0
Karsten Hopp 999485
+ static char* (*py3_PyUnicode_AsUTF8String)(PyObject *unicode);
Karsten Hopp 999485
+ #else
Karsten Hopp 999485
  static char* (*py3__PyUnicode_AsString)(PyObject *unicode);
Karsten Hopp 999485
+ #endif
Karsten Hopp 999485
  static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors);
Karsten Hopp 999485
  static char* (*py3_PyBytes_AsString)(PyObject *bytes);
Karsten Hopp 999485
  static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, int *length);
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 397,403 ****
Karsten Hopp 999485
--- 406,416 ----
Karsten Hopp 999485
      {"PyObject_Init", (PYTHON_PROC*)&py3__PyObject_Init},
Karsten Hopp 999485
      {"PyModule_AddObject", (PYTHON_PROC*)&py3_PyModule_AddObject},
Karsten Hopp 999485
      {"PyImport_AppendInittab", (PYTHON_PROC*)&py3_PyImport_AppendInittab},
Karsten Hopp 999485
+ #if PY_VERSION_HEX >= 0x030300f0
Karsten Hopp 999485
+     {"PyUnicode_AsUTF8String", (PYTHON_PROC*)&py3_PyUnicode_AsUTF8String},
Karsten Hopp 999485
+ #else
Karsten Hopp 999485
      {"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString},
Karsten Hopp 999485
+ #endif
Karsten Hopp 999485
      {"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
Karsten Hopp 999485
      {"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize},
Karsten Hopp 999485
      {"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString},
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 490,495 ****
Karsten Hopp 999485
--- 503,514 ----
Karsten Hopp 999485
  
Karsten Hopp 999485
      /* Load unicode functions separately as only the ucs2 or the ucs4 functions
Karsten Hopp 999485
       * will be present in the library. */
Karsten Hopp 999485
+ #if PY_VERSION_HEX >= 0x030300f0
Karsten Hopp 999485
+     ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString");
Karsten Hopp 999485
+     ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode");
Karsten Hopp 999485
+     ucs_as_encoded_string = symbol_from_dll(hinstPy3,
Karsten Hopp 999485
+ 	    "PyUnicode_AsEncodedString");
Karsten Hopp 999485
+ #else
Karsten Hopp 999485
      ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString");
Karsten Hopp 999485
      ucs_decode = symbol_from_dll(hinstPy3,
Karsten Hopp 999485
  	    "PyUnicodeUCS2_Decode");
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 504,509 ****
Karsten Hopp 999485
--- 523,529 ----
Karsten Hopp 999485
  	ucs_as_encoded_string = symbol_from_dll(hinstPy3,
Karsten Hopp 999485
  		"PyUnicodeUCS4_AsEncodedString");
Karsten Hopp 999485
      }
Karsten Hopp 999485
+ #endif
Karsten Hopp 999485
      if (ucs_from_string && ucs_decode && ucs_as_encoded_string)
Karsten Hopp 999485
      {
Karsten Hopp 999485
  	py3_PyUnicode_FromString = ucs_from_string;
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 600,607 ****
Karsten Hopp 999485
  
Karsten Hopp 999485
  #define GET_ATTR_STRING(name, nameobj) \
Karsten Hopp 999485
      char	*name = ""; \
Karsten Hopp 999485
!     if(PyUnicode_Check(nameobj)) \
Karsten Hopp 999485
!         name = _PyUnicode_AsString(nameobj)
Karsten Hopp 999485
  
Karsten Hopp 999485
  #define PY3OBJ_DELETED(obj) (obj->ob_base.ob_refcnt<=0)
Karsten Hopp 999485
  
Karsten Hopp 999485
--- 620,627 ----
Karsten Hopp 999485
  
Karsten Hopp 999485
  #define GET_ATTR_STRING(name, nameobj) \
Karsten Hopp 999485
      char	*name = ""; \
Karsten Hopp 999485
!     if (PyUnicode_Check(nameobj)) \
Karsten Hopp 999485
! 	name = _PyUnicode_AsString(nameobj)
Karsten Hopp 999485
  
Karsten Hopp 999485
  #define PY3OBJ_DELETED(obj) (obj->ob_base.ob_refcnt<=0)
Karsten Hopp 999485
  
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 704,709 ****
Karsten Hopp 999485
--- 724,731 ----
Karsten Hopp 999485
  	Py_SetPythonHome(PYTHON3_HOME);
Karsten Hopp 999485
  #endif
Karsten Hopp 999485
  
Karsten Hopp 999485
+ 	PyImport_AppendInittab("vim", Py3Init_vim);
Karsten Hopp 999485
+ 
Karsten Hopp 999485
  #if !defined(MACOS) || defined(MACOS_X_UNIX)
Karsten Hopp 999485
  	Py_Initialize();
Karsten Hopp 999485
  #else
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 719,726 ****
Karsten Hopp 999485
  	if (PythonIO_Init())
Karsten Hopp 999485
  	    goto fail;
Karsten Hopp 999485
  
Karsten Hopp 999485
- 	PyImport_AppendInittab("vim", Py3Init_vim);
Karsten Hopp 999485
- 
Karsten Hopp 999485
  	globals = PyModule_GetDict(PyImport_AddModule("__main__"));
Karsten Hopp 999485
  
Karsten Hopp 999485
  	/* Remove the element from sys.path that was added because of our
Karsten Hopp 999485
--- 741,746 ----
Karsten Hopp 999485
*** ../vim-7.3.687/src/version.c	2012-10-11 04:44:26.000000000 +0200
Karsten Hopp 999485
--- src/version.c	2012-10-14 03:00:57.000000000 +0200
Karsten Hopp 999485
***************
Karsten Hopp 999485
*** 721,722 ****
Karsten Hopp 999485
--- 721,724 ----
Karsten Hopp 999485
  {   /* Add new patch number below this line */
Karsten Hopp 999485
+ /**/
Karsten Hopp 999485
+     688,
Karsten Hopp 999485
  /**/
Karsten Hopp 999485
Karsten Hopp 999485
-- 
Karsten Hopp 999485
The problem with political jokes is that they get elected.
Karsten Hopp 999485
Karsten Hopp 999485
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 999485
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 999485
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 999485
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///