[pypy-commit] pypy cffi_dlopen_unicode: rework to fix win32 translation
mattip
pypy.commits at gmail.com
Sun Oct 7 13:33:34 EDT 2018
Author: Matti Picus <matti.picus at gmail.com>
Branch: cffi_dlopen_unicode
Changeset: r95185:7013b39caaa8
Date: 2018-10-07 20:33 +0300
http://bitbucket.org/pypy/pypy/changeset/7013b39caaa8/
Log: rework to fix win32 translation
diff --git a/pypy/module/_cffi_backend/cdlopen.py b/pypy/module/_cffi_backend/cdlopen.py
--- a/pypy/module/_cffi_backend/cdlopen.py
+++ b/pypy/module/_cffi_backend/cdlopen.py
@@ -23,23 +23,26 @@
def __init__(self, ffi, w_filename, flags):
space = ffi.space
- _scoped = rffi.scoped_str2charp
- _dlopen = dlopen
if WIN32 and space.isinstance_w(w_filename, space.w_unicode):
- _scoped = rffi.scoped_unicode2wcharp
- _dlopen = dlopenU
fname = space.unicode_w(w_filename)
- elif space.is_none(w_filename):
- fname = None
+ with rffi.scoped_unicode2wcharp(fname) as ll_libname:
+ fname = fname.encode('utf-8')
+ try:
+ handle = dlopenU(ll_libname, flags)
+ except DLOpenError as e:
+ raise wrap_dlopenerror(space, e, fname)
else:
- fname = space.text_w(w_filename)
- with _scoped(fname) as ll_libname:
- if fname is None:
- fname = "<None>"
- try:
- handle = _dlopen(ll_libname, flags)
- except DLOpenError as e:
- raise wrap_dlopenerror(space, e, fname)
+ if space.is_none(w_filename):
+ fname = None
+ else:
+ fname = space.text_w(w_filename)
+ with rffi.scoped_str2charp(fname) as ll_libname:
+ if fname is None:
+ fname = "<None>"
+ try:
+ handle = dlopen(ll_libname, flags)
+ except DLOpenError as e:
+ raise wrap_dlopenerror(space, e, fname)
W_LibObject.__init__(self, ffi, fname)
self.libhandle = handle
self.register_finalizer(space)
More information about the pypy-commit
mailing list