Skip to content

Commit 556684f

Browse files
committed
patch 8.2.0068: crash when using Python 3 with "utf32" encoding
Problem: Crash when using Python 3 with "utf32" encoding. (Dominique Pelle) Solution: Use "utf-8" whenever enc_utf8 is set. (closes #5423)
1 parent ef14054 commit 556684f

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/if_py_both.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static char_u e_py_systemexit[] = "E880: Can't handle SystemExit of %s exception
1919
typedef int Py_ssize_t; // Python 2.4 and earlier don't have this type.
2020
#endif
2121

22-
#define ENC_OPT ((char *)p_enc)
22+
#define ENC_OPT (enc_utf8 ? "utf-8" : (char *)p_enc)
2323
#define DOPY_FUNC "_vim_pydo"
2424

2525
static const char *vim_special_path = "_vim_path_";

src/testdir/test_python3.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,10 @@ func Test_Catch_Exception_Message()
167167
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
168168
endtry
169169
endfunc
170+
171+
func Test_unicode()
172+
" this crashed Vim once
173+
set encoding=utf32
174+
py3 print('hello')
175+
set encoding=utf8
176+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
68,
745747
/**/
746748
67,
747749
/**/

0 commit comments

Comments
 (0)