Core: do not override sys.stdin when using FreeCAD as Python module

This commit is contained in:
wmayer
2023-05-01 17:04:40 +02:00
committed by wwmayer
parent bc7ad64452
commit dc9c7a3661
4 changed files with 25 additions and 6 deletions

View File

@@ -296,6 +296,7 @@ void PythonStdin::init_type()
behaviors().doc("Redirection of stdin to FreeCAD to open an input dialog");
// you must have overwritten the virtual functions
behaviors().supportRepr();
behaviors().supportGetattr();
add_varargs_method("readline",&PythonStdin::readline,"readline()");
}
@@ -316,6 +317,14 @@ Py::Object PythonStdin::repr()
return Py::String(s_out.str());
}
Py::Object PythonStdin::getattr(const char *name)
{
if (strcmp(name, "closed") == 0) {
return Py::Boolean(false);
}
return getattr_methods(name);
}
Py::Object PythonStdin::readline(const Py::Tuple& /*args*/)
{
return Py::String( (const char *)pyConsole->readline().toLatin1() );