132
old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
133
"Py_FileSystemDefaultEncoding")
134
has_enc = ctypes.c_int.in_dll(ctypes.pythonapi,
135
"Py_HasFileSystemDefaultEncoding")
136
as_utf8 = ctypes.PYFUNCTYPE(
137
ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
138
("PyUnicode_AsUTF8", ctypes.pythonapi))
132
pythonapi = getattr(ctypes, 'pythonapi', None)
133
if pythonapi is not None:
134
old_ptr = ctypes.c_void_p.in_dll(pythonapi,
135
"Py_FileSystemDefaultEncoding")
136
has_enc = ctypes.c_int.in_dll(pythonapi,
137
"Py_HasFileSystemDefaultEncoding")
138
as_utf8 = ctypes.PYFUNCTYPE(
139
ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
140
("PyUnicode_AsUTF8", pythonapi))
139
141
except (ImportError, ValueError):
140
142
return # No ctypes or not CPython implementation, do nothing
141
143
new_enc = sys.intern(new_enc)