Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1edccfa6
Kaydet (Commit)
1edccfa6
authored
May 13, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #22274: Redirect stderr=STDOUT when stdout not redirected, by Akira Li
üst
413a8e1b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
subprocess.py
Lib/subprocess.py
+4
-1
test_subprocess.py
Lib/test/test_subprocess.py
+21
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/subprocess.py
Dosyayı görüntüle @
1edccfa6
...
...
@@ -1142,7 +1142,10 @@ class Popen(object):
errread
,
errwrite
=
self
.
pipe_cloexec
()
to_close
.
update
((
errread
,
errwrite
))
elif
stderr
==
STDOUT
:
errwrite
=
c2pwrite
if
c2pwrite
is
not
None
:
errwrite
=
c2pwrite
else
:
# child's stdout is not set, use parent's stdout
errwrite
=
sys
.
__stdout__
.
fileno
()
elif
isinstance
(
stderr
,
int
):
errwrite
=
stderr
else
:
...
...
Lib/test/test_subprocess.py
Dosyayı görüntüle @
1edccfa6
...
...
@@ -285,6 +285,27 @@ class ProcessTestCase(BaseTestCase):
tf
.
seek
(
0
)
self
.
assertStderrEqual
(
tf
.
read
(),
"strawberry"
)
def
test_stderr_redirect_with_no_stdout_redirect
(
self
):
# test stderr=STDOUT while stdout=None (not set)
# - grandchild prints to stderr
# - child redirects grandchild's stderr to its stdout
# - the parent should get grandchild's stderr in child's stdout
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'import sys, subprocess;'
'rc = subprocess.call([sys.executable, "-c",'
' "import sys;"'
' "sys.stderr.write(
\'
42
\'
)"],'
' stderr=subprocess.STDOUT);'
'sys.exit(rc)'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
#NOTE: stdout should get stderr from grandchild
self
.
assertStderrEqual
(
stdout
,
b
'42'
)
self
.
assertStderrEqual
(
stderr
,
b
''
)
# should be empty
self
.
assertEqual
(
p
.
returncode
,
0
)
def
test_stdout_stderr_pipe
(
self
):
# capture stdout and stderr to the same pipe
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
...
...
Misc/NEWS
Dosyayı görüntüle @
1edccfa6
...
...
@@ -77,6 +77,9 @@ Core and Builtins
Library
-------
-
Issue
#
22274
:
In
the
subprocess
module
,
allow
stderr
to
be
redirected
to
stdout
even
when
stdout
is
not
redirected
.
Patch
by
Akira
Li
.
-
Issue
#
12045
:
Avoid
duplicate
execution
of
command
in
ctypes
.
util
.
_get_soname
().
Patch
by
Sijin
Joseph
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment