Skip to content

Commit

Permalink
fixed python2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto De Ioris committed Feb 26, 2018
1 parent da126b9 commit ded42b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Source/UnrealEnginePython/Private/UEPyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,15 @@ void unreal_engine_init_py_module()
PyObject *new_unreal_engine_module = PyImport_AddModule("unreal_engine");
#else
PyObject *new_unreal_engine_module = Py_InitModule3("unreal_engine", NULL, unreal_engine_py_doc);
ue_PyUObjectType.tp_new = PyType_GenericNew;
ue_PyUObjectType.tp_init = (initproc)unreal_engine_py_init;
ue_PyUObjectType.tp_dictoffset = offsetof(ue_PyUObject, py_dict);

if (PyType_Ready(&ue_PyUObjectType) < 0)
return;

Py_INCREF(&ue_PyUObjectType);
PyModule_AddObject(new_unreal_engine_module, "UObject", (PyObject *)&ue_PyUObjectType);
#endif
PyObject *unreal_engine_dict = PyModule_GetDict(new_unreal_engine_module);

Expand Down Expand Up @@ -3603,6 +3612,7 @@ bool do_ue_py_check_childstruct(PyObject *py_obj, UScriptStruct* parent_u_struct
return ue_py_struct->u_struct->IsChildOf(parent_u_struct);
}

#if PY_MAJOR_VERSION >= 3
static PyObject *init_unreal_engine()
{

Expand All @@ -3621,4 +3631,5 @@ static PyObject *init_unreal_engine()
PyModule_AddObject(new_unreal_engine_module, "UObject", (PyObject *)&ue_PyUObjectType);

return new_unreal_engine_module;
}
}
#endif
2 changes: 2 additions & 0 deletions Source/UnrealEnginePython/Private/UnrealEnginePython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ void FUnrealEnginePythonModule::StartupModule()
FPlatformMisc::SetEnvironmentVar(TEXT("PATH"), *ModifiedPath);
}

#if PY_MAJOR_VERSION >= 3
init_unreal_engine_builtin();
#endif

Py_Initialize();

Expand Down

0 comments on commit ded42b2

Please sign in to comment.