Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 16cf198

Browse files
milleniumbugzalox
authored andcommitted
Backported Py_DecodeLocale from 3.5
1 parent 4e0072b commit 16cf198

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/python_interpreter.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
#include "menu.h"
77
#include "directories.h"
88

9+
static wchar_t* DecodeLocale(const char* arg, size_t *size)
10+
{
11+
#ifndef PY_VERSION_HEX
12+
#error Python not included
13+
#elif PY_VERSION_HEX < 0x03050000
14+
return _Py_char2wchar(arg, size);
15+
#else
16+
return Py_DecodeLocale(arg, size);
17+
#endif
18+
}
19+
920
inline pybind11::module pyobject_from_gobj(gpointer ptr){
1021
auto obj=G_OBJECT(ptr);
1122
if(obj)
@@ -70,7 +81,7 @@ Python::Interpreter::Interpreter(){
7081
add_path(Config::get().python.site_packages);
7182
add_path(plugin_path);
7283
Py_Initialize();
73-
argv=Py_DecodeLocale("",&size);
84+
argv=DecodeLocale("",&size);
7485
PySys_SetArgv(0,&argv);
7586
auto sys=get_loaded_module("sys");
7687
auto exc_func=[](pybind11::object type,pybind11::object value,pybind11::object traceback){

0 commit comments

Comments
 (0)