From c5461efa96953b1dcb2b28cceb0f9b6a99faed92 Mon Sep 17 00:00:00 2001 From: Drekin Date: Sat, 21 Feb 2015 10:09:50 +0100 Subject: [PATCH] Fix strncpy calling convention C function strncpy from msvcrt.dll used windll loader rather than cdll. It somehow worked on 64-bit Python, but raised an exception on 32-bit Python. See #5. --- win_unicode_console/readline_hook.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win_unicode_console/readline_hook.py b/win_unicode_console/readline_hook.py index f2103a0..7946784 100644 --- a/win_unicode_console/readline_hook.py +++ b/win_unicode_console/readline_hook.py @@ -1,12 +1,12 @@ import sys, traceback -from ctypes import pythonapi, windll, c_size_t, c_char_p, c_void_p, cast, CFUNCTYPE, POINTER, addressof +from ctypes import pythonapi, cdll, c_size_t, c_char_p, c_void_p, cast, CFUNCTYPE, POINTER, addressof PyMem_Malloc = pythonapi.PyMem_Malloc PyMem_Malloc.restype = c_size_t PyMem_Malloc.argtypes = [c_size_t] -strncpy = windll.msvcrt.strncpy +strncpy = cdll.msvcrt.strncpy strncpy.restype = c_char_p strncpy.argtypes = [c_char_p, c_char_p, c_size_t]