Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.3.688
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.688
Problem:    Python 3.3 is not supported.
Solution:   Add Python 3.3 support (Ken Takata)
Files:      src/if_python3.c


*** ../vim-7.3.687/src/if_python3.c	2012-09-21 14:00:05.000000000 +0200
--- src/if_python3.c	2012-10-14 03:19:53.000000000 +0200
***************
*** 174,180 ****
  # define _PyObject_NextNotImplemented (*py3__PyObject_NextNotImplemented)
  # define PyModule_AddObject py3_PyModule_AddObject
  # define PyImport_AppendInittab py3_PyImport_AppendInittab
! # define _PyUnicode_AsString py3__PyUnicode_AsString
  # undef PyUnicode_AsEncodedString
  # define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
  # undef PyBytes_AsString
--- 174,185 ----
  # define _PyObject_NextNotImplemented (*py3__PyObject_NextNotImplemented)
  # define PyModule_AddObject py3_PyModule_AddObject
  # define PyImport_AppendInittab py3_PyImport_AppendInittab
! # if PY_VERSION_HEX >= 0x030300f0
! #  undef _PyUnicode_AsString
! #  define _PyUnicode_AsString py3_PyUnicode_AsUTF8String
! # else
! #  define _PyUnicode_AsString py3__PyUnicode_AsString
! # endif
  # undef PyUnicode_AsEncodedString
  # define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
  # undef PyBytes_AsString
***************
*** 281,287 ****
--- 286,296 ----
  static PyObject* py3__Py_TrueStruct;
  static int (*py3_PyModule_AddObject)(PyObject *m, const char *name, PyObject *o);
  static int (*py3_PyImport_AppendInittab)(const char *name, PyObject* (*initfunc)(void));
+ #if PY_VERSION_HEX >= 0x030300f0
+ static char* (*py3_PyUnicode_AsUTF8String)(PyObject *unicode);
+ #else
  static char* (*py3__PyUnicode_AsString)(PyObject *unicode);
+ #endif
  static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors);
  static char* (*py3_PyBytes_AsString)(PyObject *bytes);
  static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, int *length);
***************
*** 397,403 ****
--- 406,416 ----
      {"PyObject_Init", (PYTHON_PROC*)&py3__PyObject_Init},
      {"PyModule_AddObject", (PYTHON_PROC*)&py3_PyModule_AddObject},
      {"PyImport_AppendInittab", (PYTHON_PROC*)&py3_PyImport_AppendInittab},
+ #if PY_VERSION_HEX >= 0x030300f0
+     {"PyUnicode_AsUTF8String", (PYTHON_PROC*)&py3_PyUnicode_AsUTF8String},
+ #else
      {"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString},
+ #endif
      {"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
      {"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize},
      {"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString},
***************
*** 490,495 ****
--- 503,514 ----
  
      /* Load unicode functions separately as only the ucs2 or the ucs4 functions
       * will be present in the library. */
+ #if PY_VERSION_HEX >= 0x030300f0
+     ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString");
+     ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode");
+     ucs_as_encoded_string = symbol_from_dll(hinstPy3,
+ 	    "PyUnicode_AsEncodedString");
+ #else
      ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString");
      ucs_decode = symbol_from_dll(hinstPy3,
  	    "PyUnicodeUCS2_Decode");
***************
*** 504,509 ****
--- 523,529 ----
  	ucs_as_encoded_string = symbol_from_dll(hinstPy3,
  		"PyUnicodeUCS4_AsEncodedString");
      }
+ #endif
      if (ucs_from_string && ucs_decode && ucs_as_encoded_string)
      {
  	py3_PyUnicode_FromString = ucs_from_string;
***************
*** 600,607 ****
  
  #define GET_ATTR_STRING(name, nameobj) \
      char	*name = ""; \
!     if(PyUnicode_Check(nameobj)) \
!         name = _PyUnicode_AsString(nameobj)
  
  #define PY3OBJ_DELETED(obj) (obj->ob_base.ob_refcnt<=0)
  
--- 620,627 ----
  
  #define GET_ATTR_STRING(name, nameobj) \
      char	*name = ""; \
!     if (PyUnicode_Check(nameobj)) \
! 	name = _PyUnicode_AsString(nameobj)
  
  #define PY3OBJ_DELETED(obj) (obj->ob_base.ob_refcnt<=0)
  
***************
*** 704,709 ****
--- 724,731 ----
  	Py_SetPythonHome(PYTHON3_HOME);
  #endif
  
+ 	PyImport_AppendInittab("vim", Py3Init_vim);
+ 
  #if !defined(MACOS) || defined(MACOS_X_UNIX)
  	Py_Initialize();
  #else
***************
*** 719,726 ****
  	if (PythonIO_Init())
  	    goto fail;
  
- 	PyImport_AppendInittab("vim", Py3Init_vim);
- 
  	globals = PyModule_GetDict(PyImport_AddModule("__main__"));
  
  	/* Remove the element from sys.path that was added because of our
--- 741,746 ----
*** ../vim-7.3.687/src/version.c	2012-10-11 04:44:26.000000000 +0200
--- src/version.c	2012-10-14 03:00:57.000000000 +0200
***************
*** 721,722 ****
--- 721,724 ----
  {   /* Add new patch number below this line */
+ /**/
+     688,
  /**/

-- 
The problem with political jokes is that they get elected.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///