Skip to content

Commit 99ba17f

Browse files
Issue python#29082: Fixed loading libraries in ctypes by unicode names on Windows.
Original patch by Chi Hsuan Yen.
1 parent c8a752e commit 99ba17f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Lib/ctypes/test/test_loading.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from ctypes.util import find_library
55
from ctypes.test import is_resource_enabled
6+
import test.test_support as support
67

78
libc_name = None
89
if os.name == "nt":
@@ -27,6 +28,12 @@ def test_load(self):
2728
CDLL(os.path.basename(libc_name))
2829
self.assertRaises(OSError, CDLL, self.unknowndll)
2930

31+
@support.requires_unicode
32+
@unittest.skipUnless(libc_name is not None, 'could not find libc')
33+
def test_load_unicode(self):
34+
CDLL(unicode(libc_name))
35+
self.assertRaises(OSError, CDLL, unicode(self.unknowndll))
36+
3037
@unittest.skipUnless(libc_name is not None, 'could not find libc')
3138
@unittest.skipUnless(libc_name is not None and
3239
os.path.basename(libc_name) == "libc.so.6",

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Extension Modules
2323
Library
2424
-------
2525

26+
- Issue #29082: Fixed loading libraries in ctypes by unicode names on Windows.
27+
Original patch by Chi Hsuan Yen.
28+
2629
- Issue #29006: Revert change from issue #10513 for making sqlite more liable to
2730
emit "database table is locked" errors.
2831

Modules/_ctypes/callproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ static PyObject *load_library(PyObject *self, PyObject *args)
12811281
PyObject *nameobj;
12821282
PyObject *ignored;
12831283
HMODULE hMod;
1284-
if (!PyArg_ParseTuple(args, "S|O:LoadLibrary", &nameobj, &ignored))
1284+
if (!PyArg_ParseTuple(args, "O|O:LoadLibrary", &nameobj, &ignored))
12851285
return NULL;
12861286
#ifdef _UNICODE
12871287
name = alloca((PyString_Size(nameobj) + 1) * sizeof(WCHAR));

0 commit comments

Comments
 (0)