Skip to content

Commit ff200b8

Browse files
committed
Unify common logic for dlopen(str)
With the clarity that the input filename has to be a str object at this stage, we can now bring together the common logic that the win32 and posix branches took. Notice how the win32 implementation previously clearer the error if PyArgs_ParseTuple failed, only to try again with the "et" format variant (now "U" as per the previous commit). As noted in the previous comment this was moot, both because the filename argument is guaranteed to be a string at this point, and because it was used in PyUnicode_AsUTF8, which would have failed if it wasn't given a str object. Signed-off-by: Rodrigo Tobar <[email protected]>
1 parent 28003b0 commit ff200b8

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/c/_cffi_backend.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4463,23 +4463,17 @@ static void *b_do_dlopen(PyObject *args, const char **p_printable_filename,
44634463
else
44644464
{
44654465
PyObject *filename_unicode;
4466-
#ifdef MS_WIN32
4467-
if (PyArg_ParseTuple(args, "U|i:load_library", &filename_unicode, &flags))
4468-
{
4469-
*p_printable_filename = PyUnicode_AsUTF8(filename_unicode);
4470-
if (*p_printable_filename == NULL)
4471-
return NULL;
4472-
return b_do_dlopen_win32(filename_unicode, flags, *p_printable_filename);
4473-
}
4474-
PyErr_Clear();
4475-
#endif
44764466
if (!PyArg_ParseTuple(args, "U|i:load_library", &filename_unicode, &flags))
44774467
return NULL;
44784468
*p_printable_filename = PyUnicode_AsUTF8(filename_unicode);
44794469
if (*p_printable_filename == NULL) {
44804470
return NULL;
44814471
}
4472+
#ifdef MS_WIN32
4473+
return b_do_dlopen_win32(filename_unicode, flags, *p_printable_filename);
4474+
#else
44824475
return b_do_dlopen_posix(filename_unicode, flags, *p_printable_filename);
4476+
#endif
44834477
}
44844478
}
44854479

0 commit comments

Comments
 (0)