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
686057b8
Kaydet (Commit)
686057b8
authored
Haz 04, 2009
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use new form of with-statement instead of contextlib.nested().
üst
a678d94d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
12 deletions
+11
-12
filecmp.py
Lib/filecmp.py
+1
-2
support.py
Lib/test/support.py
+5
-7
test_signal.py
Lib/test/test_signal.py
+2
-2
test_urllib2net.py
Lib/test/test_urllib2net.py
+3
-1
No files found.
Lib/filecmp.py
Dosyayı görüntüle @
686057b8
...
...
@@ -11,7 +11,6 @@ Functions:
import
os
import
stat
import
contextlib
from
itertools
import
filterfalse
__all__
=
[
"cmp"
,
"dircmp"
,
"cmpfiles"
]
...
...
@@ -63,7 +62,7 @@ def _sig(st):
def
_do_cmp
(
f1
,
f2
):
bufsize
=
BUFSIZE
with
contextlib
.
nested
(
open
(
f1
,
'rb'
),
open
(
f2
,
'rb'
))
as
(
fp1
,
fp2
)
:
with
open
(
f1
,
'rb'
)
as
fp1
,
open
(
f2
,
'rb'
)
as
fp2
:
while
True
:
b1
=
fp1
.
read
(
bufsize
)
b2
=
fp2
.
read
(
bufsize
)
...
...
Lib/test/support.py
Dosyayı görüntüle @
686057b8
...
...
@@ -591,13 +591,11 @@ class TransientResource(object):
raise
ResourceDenied
(
"an optional resource is not available"
)
def
transient_internet
():
"""Return a context manager that raises ResourceDenied when various issues
with the Internet connection manifest themselves as exceptions."""
time_out
=
TransientResource
(
IOError
,
errno
=
errno
.
ETIMEDOUT
)
socket_peer_reset
=
TransientResource
(
socket
.
error
,
errno
=
errno
.
ECONNRESET
)
ioerror_peer_reset
=
TransientResource
(
IOError
,
errno
=
errno
.
ECONNRESET
)
return
contextlib
.
nested
(
time_out
,
socket_peer_reset
,
ioerror_peer_reset
)
# Context managers that raise ResourceDenied when various issues
# with the Internet connection manifest themselves as exceptions.
time_out
=
TransientResource
(
IOError
,
errno
=
errno
.
ETIMEDOUT
)
socket_peer_reset
=
TransientResource
(
socket
.
error
,
errno
=
errno
.
ECONNRESET
)
ioerror_peer_reset
=
TransientResource
(
IOError
,
errno
=
errno
.
ECONNRESET
)
@contextlib.contextmanager
...
...
Lib/test/test_signal.py
Dosyayı görüntüle @
686057b8
...
...
@@ -146,8 +146,8 @@ class InterProcessSignalTests(unittest.TestCase):
# re-raises information about any exceptions the child
# throws. The real work happens in self.run_test().
os_done_r
,
os_done_w
=
os
.
pipe
()
with
nested
(
closing
(
os
.
fdopen
(
os_done_r
,
'rb'
)),
closing
(
os
.
fdopen
(
os_done_w
,
'wb'
)))
as
(
done_r
,
done_w
)
:
with
closing
(
os
.
fdopen
(
os_done_r
,
'rb'
))
as
done_r
,
\
closing
(
os
.
fdopen
(
os_done_w
,
'wb'
))
as
done_w
:
child
=
os
.
fork
()
if
child
==
0
:
# In the child process; run the test and report results
...
...
Lib/test/test_urllib2net.py
Dosyayı görüntüle @
686057b8
...
...
@@ -174,7 +174,9 @@ class OtherNetworkTests(unittest.TestCase):
(
expected_err
,
url
,
req
,
type
(
err
),
err
))
self
.
assert_
(
isinstance
(
err
,
expected_err
),
msg
)
else
:
with
support
.
transient_internet
():
with
support
.
time_out
,
\
support
.
socket_peer_reset
,
\
support
.
ioerror_peer_reset
:
buf
=
f
.
read
()
f
.
close
()
debug
(
"read
%
d bytes"
%
len
(
buf
))
...
...
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