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
104c3f10
Kaydet (Commit)
104c3f10
authored
Nis 05, 2011
tarafından
Ross Lagerwall
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10963: Ensure that subprocess.communicate() never raises EPIPE.
üst
e3c11b44
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
11 deletions
+54
-11
subprocess.py
Lib/subprocess.py
+34
-11
test_subprocess.py
Lib/test/test_subprocess.py
+18
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/subprocess.py
Dosyayı görüntüle @
104c3f10
...
@@ -396,6 +396,7 @@ import types
...
@@ -396,6 +396,7 @@ import types
import
traceback
import
traceback
import
gc
import
gc
import
signal
import
signal
import
errno
# Exception classes used by this module.
# Exception classes used by this module.
class
CalledProcessError
(
Exception
):
class
CalledProcessError
(
Exception
):
...
@@ -427,7 +428,6 @@ if mswindows:
...
@@ -427,7 +428,6 @@ if mswindows:
else
:
else
:
import
select
import
select
_has_poll
=
hasattr
(
select
,
'poll'
)
_has_poll
=
hasattr
(
select
,
'poll'
)
import
errno
import
fcntl
import
fcntl
import
pickle
import
pickle
...
@@ -726,7 +726,11 @@ class Popen(object):
...
@@ -726,7 +726,11 @@ class Popen(object):
stderr
=
None
stderr
=
None
if
self
.
stdin
:
if
self
.
stdin
:
if
input
:
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
()
self
.
stdin
.
close
()
elif
self
.
stdout
:
elif
self
.
stdout
:
stdout
=
self
.
stdout
.
read
()
stdout
=
self
.
stdout
.
read
()
...
@@ -956,7 +960,11 @@ class Popen(object):
...
@@ -956,7 +960,11 @@ class Popen(object):
if
self
.
stdin
:
if
self
.
stdin
:
if
input
is
not
None
:
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
()
self
.
stdin
.
close
()
if
self
.
stdout
:
if
self
.
stdout
:
...
@@ -1336,9 +1344,16 @@ class Popen(object):
...
@@ -1336,9 +1344,16 @@ class Popen(object):
for
fd
,
mode
in
ready
:
for
fd
,
mode
in
ready
:
if
mode
&
select
.
POLLOUT
:
if
mode
&
select
.
POLLOUT
:
chunk
=
input
[
input_offset
:
input_offset
+
_PIPE_BUF
]
chunk
=
input
[
input_offset
:
input_offset
+
_PIPE_BUF
]
input_offset
+=
os
.
write
(
fd
,
chunk
)
try
:
if
input_offset
>=
len
(
input
):
input_offset
+=
os
.
write
(
fd
,
chunk
)
close_unregister_and_remove
(
fd
)
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EPIPE
:
close_unregister_and_remove
(
fd
)
else
:
raise
else
:
if
input_offset
>=
len
(
input
):
close_unregister_and_remove
(
fd
)
elif
mode
&
select_POLLIN_POLLPRI
:
elif
mode
&
select_POLLIN_POLLPRI
:
data
=
os
.
read
(
fd
,
4096
)
data
=
os
.
read
(
fd
,
4096
)
if
not
data
:
if
not
data
:
...
@@ -1377,11 +1392,19 @@ class Popen(object):
...
@@ -1377,11 +1392,19 @@ class Popen(object):
if
self
.
stdin
in
wlist
:
if
self
.
stdin
in
wlist
:
chunk
=
input
[
input_offset
:
input_offset
+
_PIPE_BUF
]
chunk
=
input
[
input_offset
:
input_offset
+
_PIPE_BUF
]
bytes_written
=
os
.
write
(
self
.
stdin
.
fileno
(),
chunk
)
try
:
input_offset
+=
bytes_written
bytes_written
=
os
.
write
(
self
.
stdin
.
fileno
(),
chunk
)
if
input_offset
>=
len
(
input
):
except
OSError
as
e
:
self
.
stdin
.
close
()
if
e
.
errno
==
errno
.
EPIPE
:
write_set
.
remove
(
self
.
stdin
)
self
.
stdin
.
close
()
write_set
.
remove
(
self
.
stdin
)
else
:
raise
else
:
input_offset
+=
bytes_written
if
input_offset
>=
len
(
input
):
self
.
stdin
.
close
()
write_set
.
remove
(
self
.
stdin
)
if
self
.
stdout
in
rlist
:
if
self
.
stdout
in
rlist
:
data
=
os
.
read
(
self
.
stdout
.
fileno
(),
1024
)
data
=
os
.
read
(
self
.
stdout
.
fileno
(),
1024
)
...
...
Lib/test/test_subprocess.py
Dosyayı görüntüle @
104c3f10
...
@@ -597,6 +597,24 @@ class ProcessTestCase(BaseTestCase):
...
@@ -597,6 +597,24 @@ class ProcessTestCase(BaseTestCase):
self
.
assertFalse
(
os
.
path
.
exists
(
ofname
))
self
.
assertFalse
(
os
.
path
.
exists
(
ofname
))
self
.
assertFalse
(
os
.
path
.
exists
(
efname
))
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
(
"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
(
"x"
*
2
**
20
)
# context manager
# context manager
class
_SuppressCoreFiles
(
object
):
class
_SuppressCoreFiles
(
object
):
...
...
Misc/NEWS
Dosyayı görüntüle @
104c3f10
...
@@ -47,6 +47,8 @@ Core and Builtins
...
@@ -47,6 +47,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #10963: Ensure that subprocess.communicate() never raises EPIPE.
- Issue #11662: Make urllib and urllib2 ignore redirections if the
- Issue #11662: Make urllib and urllib2 ignore redirections if the
scheme is not HTTP, HTTPS or FTP (CVE-2011-1521).
scheme is not HTTP, HTTPS or FTP (CVE-2011-1521).
...
...
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