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
0b9ea93a
Kaydet (Commit)
0b9ea93a
authored
Nis 05, 2011
tarafından
Ross Lagerwall
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge with 3.2
üst
7a8d0811
02ba73c0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
11 deletions
+55
-11
subprocess.py
Lib/subprocess.py
+34
-11
test_subprocess.py
Lib/test/test_subprocess.py
+19
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/subprocess.py
Dosyayı görüntüle @
0b9ea93a
...
...
@@ -348,6 +348,7 @@ import gc
import
signal
import
builtins
import
warnings
import
errno
# Exception classes used by this module.
class
SubprocessError
(
Exception
):
pass
...
...
@@ -396,7 +397,6 @@ if mswindows:
else
:
import
select
_has_poll
=
hasattr
(
select
,
'poll'
)
import
errno
import
fcntl
import
pickle
...
...
@@ -826,7 +826,11 @@ class Popen(object):
stderr
=
None
if
self
.
stdin
:
if
input
:
self
.
stdin
.
write
(
input
)
try
:
self
.
stdin
.
write
(
input
)
except
IOError
as
e
:
if
e
.
errno
!=
errno
.
EPIPE
and
e
.
errno
!=
errno
.
EINVAL
:
raise
self
.
stdin
.
close
()
elif
self
.
stdout
:
stdout
=
self
.
stdout
.
read
()
...
...
@@ -1104,7 +1108,11 @@ class Popen(object):
if
self
.
stdin
:
if
input
is
not
None
:
self
.
stdin
.
write
(
input
)
try
:
self
.
stdin
.
write
(
input
)
except
IOError
as
e
:
if
e
.
errno
!=
errno
.
EPIPE
:
raise
self
.
stdin
.
close
()
# Wait for the reader threads, or time out. If we time out, the
...
...
@@ -1621,9 +1629,16 @@ class Popen(object):
if
mode
&
select
.
POLLOUT
:
chunk
=
self
.
_input
[
self
.
_input_offset
:
self
.
_input_offset
+
_PIPE_BUF
]
self
.
_input_offset
+=
os
.
write
(
fd
,
chunk
)
if
self
.
_input_offset
>=
len
(
self
.
_input
):
close_unregister_and_remove
(
fd
)
try
:
self
.
_input_offset
+=
os
.
write
(
fd
,
chunk
)
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EPIPE
:
close_unregister_and_remove
(
fd
)
else
:
raise
else
:
if
self
.
_input_offset
>=
len
(
self
.
_input
):
close_unregister_and_remove
(
fd
)
elif
mode
&
select_POLLIN_POLLPRI
:
data
=
os
.
read
(
fd
,
4096
)
if
not
data
:
...
...
@@ -1691,11 +1706,19 @@ class Popen(object):
if
self
.
stdin
in
wlist
:
chunk
=
self
.
_input
[
self
.
_input_offset
:
self
.
_input_offset
+
_PIPE_BUF
]
bytes_written
=
os
.
write
(
self
.
stdin
.
fileno
(),
chunk
)
self
.
_input_offset
+=
bytes_written
if
self
.
_input_offset
>=
len
(
self
.
_input
):
self
.
stdin
.
close
()
self
.
_write_set
.
remove
(
self
.
stdin
)
try
:
bytes_written
=
os
.
write
(
self
.
stdin
.
fileno
(),
chunk
)
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EPIPE
:
self
.
stdin
.
close
()
self
.
_write_set
.
remove
(
self
.
stdin
)
else
:
raise
else
:
self
.
_input_offset
+=
bytes_written
if
self
.
_input_offset
>=
len
(
self
.
_input
):
self
.
stdin
.
close
()
self
.
_write_set
.
remove
(
self
.
stdin
)
if
self
.
stdout
in
rlist
:
data
=
os
.
read
(
self
.
stdout
.
fileno
(),
1024
)
...
...
Lib/test/test_subprocess.py
Dosyayı görüntüle @
0b9ea93a
...
...
@@ -720,6 +720,25 @@ class ProcessTestCase(BaseTestCase):
self
.
assertFalse
(
os
.
path
.
exists
(
ofname
))
self
.
assertFalse
(
os
.
path
.
exists
(
efname
))
def
test_communicate_epipe
(
self
):
# Issue 10963: communicate() should hide EPIPE
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'pass'
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
self
.
addCleanup
(
p
.
stdout
.
close
)
self
.
addCleanup
(
p
.
stderr
.
close
)
self
.
addCleanup
(
p
.
stdin
.
close
)
p
.
communicate
(
b
"x"
*
2
**
20
)
def
test_communicate_epipe_only_stdin
(
self
):
# Issue 10963: communicate() should hide EPIPE
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
'pass'
],
stdin
=
subprocess
.
PIPE
)
self
.
addCleanup
(
p
.
stdin
.
close
)
time
.
sleep
(
2
)
p
.
communicate
(
b
"x"
*
2
**
20
)
# context manager
class
_SuppressCoreFiles
(
object
):
...
...
Misc/NEWS
Dosyayı görüntüle @
0b9ea93a
...
...
@@ -94,6 +94,8 @@ Core and Builtins
Library
-------
- Issue #10963: Ensure that subprocess.communicate() never raises EPIPE.
- Issue #10791: Implement missing method GzipFile.read1(), allowing GzipFile
to be wrapped in a TextIOWrapper. Patch by Nadeem Vawda.
...
...
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