mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Stop $() from silently capturing stderr (#4336)
* Stop $() from silently capturing stderr * Add test
This commit is contained in:
parent
9b79e4186e
commit
86f02c0341
3 changed files with 37 additions and 0 deletions
23
news/capture-stdout-without-stderr.rst
Normal file
23
news/capture-stdout-without-stderr.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* $() no longer silently captures stderr
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -47,6 +47,18 @@ def test_cmds_to_specs_thread_subproc(xession):
|
|||
assert specs[0].cls is ProcProxy
|
||||
|
||||
|
||||
@pytest.mark.parametrize("thread_subprocs", [True, False])
|
||||
def test_cmds_to_specs_capture_stdout_not_stderr(thread_subprocs):
|
||||
env = XSH.env
|
||||
cmds = (["ls", "/root"],)
|
||||
|
||||
env["THREAD_SUBPROCS"] = thread_subprocs
|
||||
|
||||
specs = cmds_to_specs(cmds, captured="stdout")
|
||||
assert specs[0].stdout is not None
|
||||
assert specs[0].stderr is None
|
||||
|
||||
|
||||
@skip_if_on_windows
|
||||
@pytest.mark.parametrize(
|
||||
"thread_subprocs, capture_always", list(itertools.product((True, False), repeat=2))
|
||||
|
|
|
@ -776,6 +776,8 @@ def _update_last_spec(last):
|
|||
# set standard error
|
||||
if last.stderr is not None:
|
||||
pass
|
||||
elif captured == "stdout":
|
||||
pass
|
||||
elif captured == "object":
|
||||
r, w = os.pipe()
|
||||
last.stderr = safe_open(w, "w")
|
||||
|
|
Loading…
Add table
Reference in a new issue