Skip to content

Commit ded42b2

Browse files
author
Roberto De Ioris
committed
fixed python2 support
1 parent da126b9 commit ded42b2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,15 @@ void unreal_engine_init_py_module()
18681868
PyObject *new_unreal_engine_module = PyImport_AddModule("unreal_engine");
18691869
#else
18701870
PyObject *new_unreal_engine_module = Py_InitModule3("unreal_engine", NULL, unreal_engine_py_doc);
1871+
ue_PyUObjectType.tp_new = PyType_GenericNew;
1872+
ue_PyUObjectType.tp_init = (initproc)unreal_engine_py_init;
1873+
ue_PyUObjectType.tp_dictoffset = offsetof(ue_PyUObject, py_dict);
1874+
1875+
if (PyType_Ready(&ue_PyUObjectType) < 0)
1876+
return;
1877+
1878+
Py_INCREF(&ue_PyUObjectType);
1879+
PyModule_AddObject(new_unreal_engine_module, "UObject", (PyObject *)&ue_PyUObjectType);
18711880
#endif
18721881
PyObject *unreal_engine_dict = PyModule_GetDict(new_unreal_engine_module);
18731882

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

3615+
#if PY_MAJOR_VERSION >= 3
36063616
static PyObject *init_unreal_engine()
36073617
{
36083618

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

36233633
return new_unreal_engine_module;
3624-
}
3634+
}
3635+
#endif

Source/UnrealEnginePython/Private/UnrealEnginePython.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,9 @@ void FUnrealEnginePythonModule::StartupModule()
334334
FPlatformMisc::SetEnvironmentVar(TEXT("PATH"), *ModifiedPath);
335335
}
336336

337+
#if PY_MAJOR_VERSION >= 3
337338
init_unreal_engine_builtin();
339+
#endif
338340

339341
Py_Initialize();
340342

0 commit comments

Comments
 (0)