diff src/if_python3.c @ 5164:b3bd43ef012d v7.4a.008

updated for version 7.4a.008 Problem: Python 3 doesn't handle multibyte characters prooperly when 'encoding' is not utf-8. Solution: Use PyUnicode_Decode() instead of PyUnicode_FromString(). (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Tue, 09 Jul 2013 17:30:55 +0200
parents f063be86b632
children 46ca8fcee525
line wrap: on
line diff
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -86,7 +86,8 @@
 #ifndef PyString_Check
 # define PyString_Check(obj) PyUnicode_Check(obj)
 #endif
-#define PyString_FromString(repr) PyUnicode_FromString(repr)
+#define PyString_FromString(repr) \
+    PyUnicode_Decode(repr, STRLEN(repr), ENC_OPT, NULL)
 #define PyString_FromFormat PyUnicode_FromFormat
 #ifndef PyInt_Check
 # define PyInt_Check(obj) PyLong_Check(obj)