Skip to content

Commit

Permalink
Fix strncpy calling convention
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Drekin committed Feb 21, 2015
1 parent 37c5bd6 commit c5461ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions win_unicode_console/readline_hook.py
Original file line number Diff line number Diff line change
@@ -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]

Expand Down

0 comments on commit c5461ef

Please sign in to comment.