2

I have a script _testing_.py containing just raise SystemExit. When I run it from cmdline using py -i _testing_.py, the traceback is printed and the the prompt >>> is printed. However when I run it as subprocess via Popen, i.e. Popen("py -i _testing_.py", stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate() the resulting stderr contains first the prompt >>> and then the traceback. Can you confirm this behaviour and explain it? I'm using Python 3.3.2 on Windows.

It seems thats it's dependent bahaviour. @jentyk's observation is that the order isn't exchanged in Python 2.7 on MacOS.

user87690
  • 687
  • 3
  • 25
  • Can you drop in a full runable script showing the second behavior? – agf Aug 24 '13 at 14:51
  • @agf: I almost have: `from subprocess import *; print(Popen("py -i _testing_.py", stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()[1].decode())`. (The resulting stderr is bytes in the second element of the result of .communicate().) – user87690 Aug 24 '13 at 15:00
  • 1
    Maybe it helps. I just tried under Python 2.7 on Mac OS X, and it works in both cases the same, I mean prompt after traceback. It can mean the behaviour you observed is Python version or operating system specific. – Lukasz Aug 24 '13 at 15:37
  • 1
    Wow! I just run it under Python 3.3 and indeed prompt is at the beginning! Weird... – Lukasz Aug 24 '13 at 15:47
  • Possibly related: http://stackoverflow.com/questions/18419787/where-does-pythons-interactive-prompt-output-to – Fred Foo Aug 24 '13 at 16:06

0 Answers0