py3: Gui: files A-P ported to python3
This commit is contained in:
@@ -81,7 +81,11 @@ Py::Object PythonStdout::write(const Py::Tuple& args)
|
||||
if (PyUnicode_Check(output.ptr())) {
|
||||
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
|
||||
if (unicode) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
const char* string = PyBytes_AsString(unicode);
|
||||
#else
|
||||
const char* string = PyString_AsString(unicode);
|
||||
#endif
|
||||
int maxlen = qstrlen(string) > 10000 ? 10000 : -1;
|
||||
pyConsole->insertPythonOutput(QString::fromUtf8(string, maxlen));
|
||||
Py_DECREF(unicode);
|
||||
@@ -152,7 +156,11 @@ Py::Object PythonStderr::write(const Py::Tuple& args)
|
||||
if (PyUnicode_Check(output.ptr())) {
|
||||
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
|
||||
if (unicode) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
const char* string = PyBytes_AsString(unicode);
|
||||
#else
|
||||
const char* string = PyString_AsString(unicode);
|
||||
#endif
|
||||
int maxlen = qstrlen(string) > 10000 ? 10000 : -1;
|
||||
pyConsole->insertPythonError(QString::fromUtf8(string, maxlen));
|
||||
Py_DECREF(unicode);
|
||||
@@ -222,7 +230,11 @@ Py::Object OutputStdout::write(const Py::Tuple& args)
|
||||
if (PyUnicode_Check(output.ptr())) {
|
||||
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
|
||||
if (unicode) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
const char* string = PyBytes_AsString(unicode);
|
||||
#else
|
||||
const char* string = PyString_AsString(unicode);
|
||||
#endif
|
||||
Base::Console().Message("%s",string);
|
||||
Py_DECREF(unicode);
|
||||
}
|
||||
@@ -290,7 +302,11 @@ Py::Object OutputStderr::write(const Py::Tuple& args)
|
||||
if (PyUnicode_Check(output.ptr())) {
|
||||
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
|
||||
if (unicode) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
const char* string = PyBytes_AsString(unicode);
|
||||
#else
|
||||
const char* string = PyString_AsString(unicode);
|
||||
#endif
|
||||
Base::Console().Error("%s",string);
|
||||
Py_DECREF(unicode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user