Hi, 2010/2/17 stephen <step...@blackroses.com>
> Hello, > > THE PROBLEM: > I am having a problem that I have seen asked quite a bit on the web, with > little to no follow up. > The problem is essentially this. When embedding (LoadLibraryA()) the python > interpreter dll > in a non-windows application the developer must first create a console for > python to do output/input with. > I properly initialize the CRT and AllocConsole() to do this. I then > GetSTDHandle() for stdin and stdout accordingly > and open those handles with the requisite flags "read" for STDIN and > "write" for stdout. This all works great > and is then verified and tested to work by printf() and fgets(). This issue > however happens when attempting > to PyRun_InteractiveLoop() and PyRun_SimpleString(). A > PyRun_SimpleString("print 'test'") displays nothing in my > freshly allocated console window. Similarly a PyRun_InteractiveLoop(stdin, > NULL); yields nothing either even though > the line printf("testing"); directly ahead of it works just fine. Does > anyone have insight on how I can make this work > with the freshly allocated console's stdin/stdout/stderr? > > SPECULATION: > That is the question, so now on to the speculation. I suspect that > something in the python runtime doesn't "get handles" > correctly for STDIN and STDOUT upon initialization. I have perused the > source code to find out exactly how this is done > and I suspect that it starts in PyInitializeEx with calls to > PySys_GetObject("stdin") and "stdout" accordingly. However I > don't actually see where this translates into the Python runtime checking > with the C-runtime for the "real" handles to STDIN and STDOUT. I dont ever > see the Python runtime "ask the system" where his handles to STDIN and > STDOUT are. > Are you using the same compiler as the one used to compile Python? It's important that your program and python use the same C runtime library (MSVCR90.dll for python 2.6), otherwise "stdout" refers to different things. -- Amaury Forgeot d'Arc
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com