Skip to content

Commit

Permalink
Python plugin: Use only the Python stable ABI
Browse files Browse the repository at this point in the history
TODO: Still need to find alternative to PyRun_SimpleString.
  • Loading branch information
bjorn committed May 16, 2018
1 parent 82b98df commit fa939ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/plugins/python/python.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import qbs.FileInfo
TiledPlugin {
Depends { name: "Qt"; submodules: ["widgets"] }

cpp.defines: base.concat(["Py_LIMITED_API=0x03040000"])

condition: {
if (qbs.targetOS.contains("windows"))
return File.exists(Environment.getEnv("PYTHONHOME"));
Expand Down
8 changes: 2 additions & 6 deletions src/plugins/python/pythonplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ void PythonPlugin::initialize()
addObject(&mLogger);

if (!Py_IsInitialized()) {
// PEP370
Py_NoSiteFlag = 1;
Py_NoUserSiteDirectory = 1;

PyImport_AppendInittab("tiled", PyInit_tiled);
PyImport_AppendInittab("tiled.qt", PyInit_tiled);
PyImport_AppendInittab("tiled.Tiled", PyInit_tiled);
Expand Down Expand Up @@ -368,7 +364,7 @@ QString PythonMapFormat::nameFilter() const
PySys_WriteStderr("** Uncaught exception in script **\n");
} else {
PyObject* pyStr = PyUnicode_AsEncodedString(pinst, "utf-8", "Error ~");
ret = PyBytes_AS_STRING(pyStr);
ret = PyBytes_AsString(pyStr);
Py_XDECREF(pyStr);
Py_DECREF(pinst);
}
Expand Down Expand Up @@ -396,7 +392,7 @@ QString PythonMapFormat::shortName() const
PySys_WriteStderr("** Uncaught exception in script **\n");
} else {
PyObject* pyStr = PyUnicode_AsEncodedString(pinst, "utf-8", "Error ~");
ret = PyBytes_AS_STRING(pyStr);
ret = PyBytes_AsString(pyStr);
Py_XDECREF(pyStr);
Py_DECREF(pinst);
}
Expand Down

0 comments on commit fa939ef

Please sign in to comment.