Menu

#820 Standalone python application have an erroneous behavior with the std module

svn version
closed-works-for-me
nobody
None
5
2016-01-06
2016-01-05
rgiot
No

It seems that tulip overrides the std module because :

  • write to stderr is prefixed by [PythonStdErr]
  • write to stdout is prefixed by [PythonStdOut]
  • exit function does not exists

For example, the following script:
from tulip import *
from tulipgui import *
from tulipogl import *
import sys
sys.stdout.write("Stdout test\n")
sys.stderr.write("Stderr test\n")
sys.exit(3)

produces the following result:
[PythonStdOut] "Stdout test"
[PythonStdErr] "Stderr test"
[PythonStdErr] "Traceback (most recent call last):"
[PythonStdErr] " File "scripts/test.py", line 14, in <module>"
[PythonStdErr] " sys.exit(-1)"
[PythonStdErr] "AttributeError: 'module' object has no attribute 'exit'"</module>

with an exit code of 1

instead of
Stdout test
Stderr test

with an exit code of 3

Discussion

  • Antoine Lambert

    Antoine Lambert - 2016-01-05

    Hi,

    I can not reproduce your issue with Tulip 4.8

    If I launch your script through the classical Python interpreter, I got the correct output and no errors.

    Nevertheless, the embedded interpreter in the Tulip software overrides the standard output in order to redirect it to the console and log widgets. The 'exit' function is also removed as it could crash Tulip. That environment customization is only applied when no interpreter instance already exists (this is not the case when launching a script trough the
    python command).

    Antoine

     
  • rgiot

    rgiot - 2016-01-06

    Hi

    I guess my description was not enought precise ;) Of course the issue accurs when I launch the script through the python command.

    However, I was not using the very last version of the trunk. After an update to revision 11173, I noticed the issue was solved.

    Sorry for the noise ; a bug fix should have been committed in december

     
  • Patrick Mary

    Patrick Mary - 2016-01-06
    • status: open --> closed-works-for-me
     
  • Patrick Mary

    Patrick Mary - 2016-01-06

    At this time, this bug seems to be fixed in the current svn code line,
    since a recent (but undated) commit .

     

Log in to post a comment.

MongoDB Logo MongoDB