Committing this for Larry D'Anna:

This patch adds support for passing an arbitrary python stream
(anything inheriting from IOBase) to SetOutputFileHandle or
SetErrorFileHandle.

Differential revision: https://reviews.llvm.org/D38829
<rdar://problem/34870417> 

llvm-svn: 315966
This commit is contained in:
Jason Molenda
2017-10-17 03:03:44 +00:00
parent 45623bd06d
commit 695a1f6e6c
10 changed files with 302 additions and 21 deletions

View File

@@ -504,7 +504,7 @@ void ScriptInterpreterPython::LeaveSession() {
}
bool ScriptInterpreterPython::SetStdHandle(File &file, const char *py_name,
PythonFile &save_file,
PythonObject &save_file,
const char *mode) {
if (file.IsValid()) {
// Flush the file before giving it to python to avoid interleaved output.
@@ -512,8 +512,7 @@ bool ScriptInterpreterPython::SetStdHandle(File &file, const char *py_name,
PythonDictionary &sys_module_dict = GetSysModuleDictionary();
save_file = sys_module_dict.GetItemForKey(PythonString(py_name))
.AsType<PythonFile>();
save_file = sys_module_dict.GetItemForKey(PythonString(py_name));
PythonFile new_file(file, mode);
sys_module_dict.SetItemForKey(PythonString(py_name), new_file);