How does one print to the REPL from the CPython source?

Not sure if I am on the right forum, so please let me know if I misconstrued the titles and descriptions. I am trying to get some printf info from compile.c to the REPL. Specifically, just to get a “hello world” of sorts, I modified compiler_for as follows:

compiler_for(struct compiler *c, stmt_ty s)
{
    basicblock *start, *body, *cleanup, *end;

    printf("entering compiler_for \n");

    start = compiler_new_block(c);
    body = compiler_new_block(c);

I built it using:

 PCbuild/build.bat -E -d -p x64

And ran it on Cygwin as:

   ./python.exe

in the amd64 library.

It is not at all surprising that this did not produce an output. I guess I could try to get it to work in the Visual Studio IDE. For whatever reason, I have had no luck building in the IDE (using the .sln), and have not yet tried opening the sln after building with the build.bat to see if the output is in the console output window. Even if it is, however, I’m guessing it would be much handier to see the result in the REPL.

Does anyone know how this is typically done (for example) by the Python contributors when they are debugging or others that make mods to the source?

Thanks!

Will I have to create the bytecode to do this?

This should generally work; I’ve putt prints in the compiler before (though not on Windows). You may have to remove any existing pyc files though.

It looks like you’re building a Windows native version of Python but trying to run it under Cygwin. This is known to be problematic due to some of the emulation tricks Cygwin uses.

Try running your newly built Python from a Command Prompt or Powershell window and see if you get output there.