This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: The order of interactive prompt and traceback on Windows
类型: behavior Stage: resolved
Components: Windows Versions: Python 3.3
process
状态: closed Resolution: out of date
Dependencies: 后续:
分配给: 抄送列表: Drekin, iritkatriel, r.david.murray
优先级: normal 关键字:

Created on 2013-08-26 09:05 by Drekin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg196192 - (view) Author: Adam Bartoš (Drekin) * 日期: 2013-08-26 09:05
On Windows, Python 3.3.2, when I run Python as a subprocess via Popen("py -i somescript.py", stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate() and somescript.py ends with exception, there is first interactive promt ">>>" in stderr output and then the traceback which is reversed to standard order when somescript.py is run interactively directly.

Corresponding StackOverflow question: http://stackoverflow.com/questions/18419724/position-of-prompt-in-stderr-after-systemexit .
msg196216 - (view) Author: R. David Murray (r.david.murray) * (Python committer) 日期: 2013-08-26 15:51
For anyone who wants to look in to this: according to the stack overflow question and comments, this is a behavior change between python2 and python3.
msg247461 - (view) Author: Adam Bartoš (Drekin) * 日期: 2015-07-27 11:20
Yes, it is a behavior change between Python 2 and Python 3. I just tried with 2.7 and 3.0.
msg381048 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) 日期: 2020-11-16 00:22
On version 3.10, windows 10 I don't see this - the prompt comes after the traceback.

Adam, are you seeing this issue on any python version >= 3.8?
msg381170 - (view) Author: Adam Bartoš (Drekin) * 日期: 2020-11-16 22:04
So far I could reproduce the issue on Python 3.7, Windows Vista 64bit. I'll try with newer versions.

The output I got:
>>> from subprocess import *
>>> Popen("py -i foo.py", stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
(b'', b'>>> Traceback (most recent call last):\r\n  File "foo.py", line 2, in <module>\r\n    1/0\r\nZeroDivisionError: division by zero\r\n\r\n')
msg381449 - (view) Author: Adam Bartoš (Drekin) * 日期: 2020-11-19 18:12
The order is fine on Python 3.8, Windows 10.
msg381450 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) 日期: 2020-11-19 18:17
Thanks. I'm closing this because 3.7 is only getting security fixes now.
历史
日期 用户 动作 参数
2022-04-11 14:57:50admin修改github: 63038
2020-11-19 18:17:25iritkatriel修改状态: open -> closed
resolution: out of date
消息: + msg381450

stage: resolved
2020-11-19 18:12:50Drekin修改消息: + msg381449
2020-11-16 22:04:38Drekin修改状态: pending -> open

消息: + msg381170
2020-11-16 00:22:09iritkatriel修改状态: open -> pending
抄送: + iritkatriel
消息: + msg381048

2015-07-27 11:20:57Drekin修改消息: + msg247461
2013-08-26 15:51:59r.david.murray修改抄送: + r.david.murray
消息: + msg196216
2013-08-26 09:05:07Drekin创建