Skip to content

Commit 7c4799a

Browse files
committed
Move win32-specific behaviour to b_do_dlopen_win32
Signed-off-by: Rodrigo Tobar <[email protected]>
1 parent ff200b8 commit 7c4799a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/c/_cffi_backend.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,6 +4396,10 @@ static void *b_do_dlopen_posix(PyObject *filename_unicode, int flags, const char
43964396
#ifdef MS_WIN32
43974397
static void *b_do_dlopen_win32(PyObject *filename_unicode, int flags, const char *printable_filename)
43984398
{
4399+
if (filename_unicode == NULL) {
4400+
PyErr_SetString(PyExc_OSError, "dlopen(None) not supported on Windows");
4401+
return NULL;
4402+
}
43994403
Py_ssize_t sz1;
44004404
wchar_t *w1;
44014405

@@ -4426,15 +4430,14 @@ static void *b_do_dlopen(PyObject *args, const char **p_printable_filename,
44264430
*auto_close = 1;
44274431

44284432
if (PyTuple_GET_SIZE(args) == 0 || PyTuple_GET_ITEM(args, 0) == Py_None) {
4429-
#ifdef MS_WIN32
4430-
PyErr_SetString(PyExc_OSError, "dlopen(None) not supported on Windows");
4431-
return NULL;
4432-
#else
44334433
PyObject *dummy;
44344434
if (!PyArg_ParseTuple(args, "|Oi:load_library",
44354435
&dummy, &flags))
44364436
return NULL;
44374437
*p_printable_filename = "<None>";
4438+
#ifdef MS_WIN32
4439+
return b_do_dlopen_win32(NULL, flags, *p_printable_filename);
4440+
#else
44384441
return b_do_dlopen_posix(NULL, flags, *p_printable_filename);
44394442
#endif
44404443
}

0 commit comments

Comments
 (0)