Skip to content

Commit

Permalink
Merge pull request #54 from OhseyDev/patch-py3
Browse files Browse the repository at this point in the history
  • Loading branch information
NobodyXu authored Mar 8, 2024
2 parents 4b1963d + 34c4315 commit c71cb99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/Callback/python3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ void Interpreter::release()

static void initialize_interpreter()
{
auto empty_wstr = Py_DecodeLocale_Checked("");

wchar_t* argv[] = {empty_wstr.str.get(), nullptr};
PySys_SetArgvEx(1, argv, 0);

Module sys("sys");

sys.setattr("stdin", Object::get_none());
Expand All @@ -141,8 +136,17 @@ void MainInterpreter::load_libpython3()
if (Py_IsInitialized())
return;

PyConfig cfg;
PyConfig_InitPythonConfig(&cfg);

auto wstr = Py_DecodeLocale_Checked("python3");
Py_SetProgramName(wstr.str.get());
cfg.program_name = wstr.str.get();
/*
* Depreciated in version 3.11: Py_SetProgramName(...)
*/
auto empty_wstr = Py_DecodeLocale_Checked("");
wchar_t* argv[] = {empty_wstr.str.get(), nullptr};
PyConfig_SetArgv(&cfg, 1, argv);

/*
* Changed in version 3.7: Py_Initialize() now initializes the GIL.
Expand Down
2 changes: 1 addition & 1 deletion src/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void visit_all_subdirs(const char *path, subdir_visiter visiter, ...)
// Check if it is a dir after resolution
if (!isdir(path, path_fd, ent->d_name))
break;
[[fallthrough]];
//[[fallthrough]];

case DT_DIR:
if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0)
Expand Down

0 comments on commit c71cb99

Please sign in to comment.