[issue10080] Py_Initialize crashes when stdout has been redirected with freopen

2010-10-13 Thread Mitchell Stokes
Changes by Mitchell Stokes : Added file: http://bugs.python.org/file19220/py_main_dup2.c ___ Python tracker <http://bugs.python.org/issue10080> ___ ___ Python-bugs-list m

[issue10080] Py_Initialize crashes when stdout has been redirected with freopen

2010-10-13 Thread Mitchell Stokes
Mitchell Stokes added the comment: I used _dup2() and I still got a crash. Also, if I use _fileno(stdout) after using freopen(), I get 1. I'm uploading two more example programs. py_main_fileno_check.c prints the fileno to the text file py_main_dup2.c uses _dup2() to redirect stdout in

[issue10080] Py_Initialize crashes when stdout has been redirected with freopen

2010-10-13 Thread Mitchell Stokes
Mitchell Stokes added the comment: Setting PYTHONIOENCODING=cp1252 does not help. Also, dup2 is not available on Windows (at least not from what I've read). >From my understanding, freopen() is supposed to be the portable way to redirec

[issue10080] Py_Initialize crashes when stdout has been redirected with freopen

2010-10-12 Thread Mitchell Stokes
New submission from Mitchell Stokes : I have Python embedded in a C/C++ program, and I'm trying to redirect stdout to a text file. Since I'm trying to get rid of the console, I want C and Python stdout going to the text file (so, not sys.stdout = open('log.txt', 'w