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
ac625351
Kaydet (Commit)
ac625351
authored
Ara 09, 2009
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7461: objects returned by os.popen() should support the context manager protocol
üst
9b14f604
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
os.py
Lib/os.py
+4
-0
test_popen.py
Lib/test/test_popen.py
+8
-0
No files found.
Lib/os.py
Dosyayı görüntüle @
ac625351
...
...
@@ -650,6 +650,10 @@ class _wrap_close:
return
returncode
else
:
return
returncode
<<
8
# Shift left to match old behavior
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
*
args
):
self
.
close
()
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
_stream
,
name
)
def
__iter__
(
self
):
...
...
Lib/test/test_popen.py
Dosyayı görüntüle @
ac625351
...
...
@@ -49,6 +49,14 @@ class PopenTest(unittest.TestCase):
else
:
self
.
assertEqual
(
os
.
popen
(
"exit 42"
)
.
close
(),
42
<<
8
)
def
test_contextmanager
(
self
):
with
os
.
popen
(
"echo hello"
)
as
f
:
self
.
assertEqual
(
f
.
read
(),
"hello
\n
"
)
def
test_iterating
(
self
):
with
os
.
popen
(
"echo hello"
)
as
f
:
self
.
assertEqual
(
list
(
f
),
[
"hello
\n
"
])
def
test_main
():
support
.
run_unittest
(
PopenTest
)
...
...
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