Python drives me mad...
Oleg Broytmann
phd at phd.russ.ru
Fri Mar 24 06:31:59 EST 2000
On Mon, 20 Mar 2000, Boris Ottlewski wrote:
> FILE *stream;
> char temp[8192];
> new_stdout = PyFile_FromString("c:\\freopen.out", "w");
> PySys_SetObject("stdout", new_stdout);
> file://PySys_SetObject("stderr", new_stdout);
> int res = PyRun_SimpleString("print 2\n");
> Py_XDECREF(new_stdout);
>
> This should print the "2" to the redirected stdout which is c:\freopen.out.
> But the file is empty!!!!!!!!!! and...I cant delete it, it is still locked
> (shouldnt Py_XDECREF close it?)
No, it shouldn't. There are more links to the object (2 links from sys
module; these links are created by you, do you remember?)
Oleg.
----
Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list