Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e08cbf1

Browse files
committed
Fix build on PyPy
It appears that `Py_FileSystemDefaultEncodeErrors` is not part of the limited API, and PyPy does not have it. Since pybind11 does not have a wrapper for `PyUnicode_EncodeFSDefault` (the main reason I had switched to a `encode` call earlier), we need to call it ourselves manually.
1 parent 43929f3 commit e08cbf1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/_tkagg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ load_tkinter_funcs()
309309
module = py::module_::import("_tkinter"); // CPython
310310
}
311311
auto py_path = module.attr("__file__");
312-
py::bytes py_path_b = py_path.attr("encode")(
313-
Py_FileSystemDefaultEncoding, Py_FileSystemDefaultEncodeErrors);
312+
auto py_path_b = py::reinterpret_steal<py::bytes>(
313+
PyUnicode_EncodeFSDefault(py_path.ptr()));
314314
std::string path = py_path_b;
315315
auto tkinter_lib = dlopen(path.c_str(), RTLD_LAZY);
316316
if (!tkinter_lib) {

0 commit comments

Comments
 (0)