summaryrefslogtreecommitdiff
path: root/testing/cffi0/test_ownlib.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2018-10-14 09:37:59 +0200
committerArmin Rigo <arigo@tunes.org>2018-10-14 09:37:59 +0200
commit6aed34efef2fc043661a309eaf891afc3a17b64e (patch)
tree2d5e8ee27570087f84ef51ba3239c970ed59f0a9 /testing/cffi0/test_ownlib.py
parent7ff5c9b50467b4b3409e424f75b90edcf8ad4c93 (diff)
downloadcffi-6aed34efef2fc043661a309eaf891afc3a17b64e.tar.gz
CPython 2.x: ``ffi.dlopen()`` failed with non-ascii file names on Posix
Diffstat (limited to 'testing/cffi0/test_ownlib.py')
-rw-r--r--testing/cffi0/test_ownlib.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/testing/cffi0/test_ownlib.py b/testing/cffi0/test_ownlib.py
index 68c3173..f4f9ee2 100644
--- a/testing/cffi0/test_ownlib.py
+++ b/testing/cffi0/test_ownlib.py
@@ -1,4 +1,4 @@
-import py, sys
+import py, sys, os
import subprocess, weakref
from cffi import FFI
from cffi.backend_ctypes import CTypesBackend
@@ -117,7 +117,6 @@ class TestOwnLib(object):
from testing.udir import udir
udir.join('testownlib.c').write(SOURCE)
if sys.platform == 'win32':
- import os
# did we already build it?
if cls.Backend is CTypesBackend:
dll_path = str(udir) + '\\testownlib1.dll' # only ascii for the ctypes backend
@@ -148,10 +147,23 @@ class TestOwnLib(object):
os.rename(str(udir) + '\\testownlib.dll', dll_path)
cls.module = dll_path
else:
+ encoded = None
+ if cls.Backend is not CTypesBackend:
+ try:
+ unicode_name = u+'testownlibcaf\xe9'
+ encoded = unicode_name.encode(sys.getfilesystemencoding())
+ if sys.version_info >= (3,):
+ encoded = str(unicode_name)
+ except UnicodeEncodeError:
+ pass
+ if encoded is None:
+ unicode_name = u+'testownlib'
+ encoded = str(unicode_name)
subprocess.check_call(
- 'cc testownlib.c -shared -fPIC -o testownlib.so',
+ "cc testownlib.c -shared -fPIC -o '%s.so'" % (encoded,),
cwd=str(udir), shell=True)
- cls.module = str(udir.join('testownlib.so'))
+ cls.module = os.path.join(str(udir), unicode_name + (u+'.so'))
+ print(repr(cls.module))
def test_getting_errno(self):
if self.module is None: