Script Console print() not working

One of my other devs brought me a odd issue. After upgrading to 8.1.10 print statements when using script console for debugging stopped working. This only happens in specific situations where a custom class is used in the script, it almost seems as though the print() is being overridden somehow. However this issue did not occur in 8.1.6, so I assume this is related to the update to jython 2.7.2

I cannot find any obvious issues, any jython experts know of changes in 2.7.2 that could cause this?

Print statements or print calls as a function? The latter would require from __future__ import print_function as the first line in whatever execution environment you’re in, on any Python 2.X version.

2 Likes

Sorry my bad lingo, print statements

Here is an example… where you see the print statement stops working after executing a function.

I’d send you the code, but way to many dependencies on our specific environment in this code, so just trying to find some help looking for a direction to investigate.

Could the code be calling System.exit() or otherwise exiting ‘too fast’? I don’t think you can non-trivially break the print statement (outside of the aforementioned magic import to turn it into a function).

If you can annotate the code you’re calling with more prints, that may help identify where in the code it’s “stopping”.

I can replicate this issue. In the attached screenshot I ran the script console twice. The first time nothing got printed after the class method was run and the second time all the prints came through fine. Every time I open a new designer this issue happens on the first execution. I am on version 8.1.10

Can either of you provide an SSCCE that demonstrates the problem?

I am running into a similar issue on 8.1.11, but on the Output Console.

This is the code on actionPerformed on a button:

from __future__ import print_function

print("Hello world!")

But when I comment the import, I get the output for all previous clicks plus the last one, at once.

Summoning @PGriffith.

Could this be flagged as a bug and fixed on 8.1.12?

CC: @cmallonee

I’ve been out for a week, but let’s get into it :slight_smile:
There’s pretty much no chance this is going to be fixed in 8.1.12; it’s too late in the game.

You posted a minimal example a few days ago, but that seems like a different issue than the main topic of this thread. It’s potentially a bug worth fixing (I’ll take a look at it) but without an SSCCE for the main issue I don’t have a lot to go forward with.

I’m still trying to put together a SSCCE for you on the primary issue, just haven’t been able to carve a few hours out to do it… :frowning:

1 Like

This doesn’t work ‘right’ because the future import print_function isn’t flushing the output stream for whatever reason.

I’ve also discovered this issue but I didn’t find a correlation between custom classes and the issue. 8.1.10

We used some logger functions though out the function we’re calling and the logs do post, but not the print statements or the return of the function.

It seems like the console output is just being dropped or truncated some how.

A second execute in the script console shows the expected output on the interpreter.