Fix SF #762455, segfault when sys.stdout is changed in getattr
Note: in 2.2, the problem was an infinite loop (at least for me).
err = -1;
}
}
+ /* PyFile_SoftSpace() can exececute arbitrary code
+ if sys.stdout is an instance with a __getattr__.
+ If __getattr__ raises an exception, w will
+ be freed, so we need to prevent that temporarily. */
+ Py_XINCREF(w);
if (w != NULL && PyFile_SoftSpace(w, 1))
err = PyFile_WriteString(" ", w);
if (err == 0)
}
#endif
}
+ Py_XDECREF(w);
Py_DECREF(v);
Py_XDECREF(stream);
stream = NULL;