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
95351056
Kaydet (Commit)
95351056
authored
Haz 18, 2011
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge #11700: proxy object close methods can now be called multiple times
üst
85198753
c88bce15
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
mailbox.py
Lib/mailbox.py
+10
-4
test_mailbox.py
Lib/test/test_mailbox.py
+12
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/mailbox.py
Dosyayı görüntüle @
95351056
...
...
@@ -1923,9 +1923,10 @@ class _ProxyFile:
def
close
(
self
):
"""Close the file."""
if
hasattr
(
self
.
_file
,
'close'
):
self
.
_file
.
close
()
del
self
.
_file
if
hasattr
(
self
,
'_file'
):
if
hasattr
(
self
.
_file
,
'close'
):
self
.
_file
.
close
()
del
self
.
_file
def
_read
(
self
,
size
,
read_method
):
"""Read size bytes using read_method."""
...
...
@@ -1957,6 +1958,10 @@ class _ProxyFile:
@property
def
closed
(
self
):
if
not
hasattr
(
self
,
'_file'
):
return
True
if
not
hasattr
(
self
.
_file
,
'closed'
):
return
False
return
self
.
_file
.
closed
...
...
@@ -1995,7 +2000,8 @@ class _PartialFile(_ProxyFile):
def
close
(
self
):
# do *not* close the underlying file object for partial files,
# since it's global to the mailbox object
del
self
.
_file
if
hasattr
(
self
,
'_file'
):
del
self
.
_file
def
_lock_file
(
f
,
dotlock
=
True
):
...
...
Lib/test/test_mailbox.py
Dosyayı görüntüle @
95351056
...
...
@@ -297,6 +297,13 @@ class TestMailbox(TestBase):
self
.
assertEqual
(
data1
.
decode
(
'ascii'
)
.
replace
(
os
.
linesep
,
'
\n
'
),
_sample_message
)
def
test_get_file_can_be_closed_twice
(
self
):
# Issue 11700
key
=
self
.
_box
.
add
(
_sample_message
)
f
=
self
.
_box
.
get_file
(
key
)
f
.
close
()
f
.
close
()
def
test_iterkeys
(
self
):
# Get keys using iterkeys()
self
.
_check_iteration
(
self
.
_box
.
keys
,
do_keys
=
True
,
do_values
=
False
)
...
...
@@ -1862,8 +1869,12 @@ class TestProxyFileBase(TestBase):
def
_test_close
(
self
,
proxy
):
# Close a file
self
.
assertFalse
(
proxy
.
closed
)
proxy
.
close
()
self
.
assertTrue
(
proxy
.
closed
)
# Issue 11700 subsequent closes should be a no-op.
proxy
.
close
()
self
.
assert
Raises
(
AttributeError
,
lambda
:
proxy
.
close
()
)
self
.
assert
True
(
proxy
.
closed
)
class
TestProxyFile
(
TestProxyFileBase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
95351056
...
...
@@ -193,6 +193,9 @@ Core and Builtins
Library
-------
- Issue #11700: mailbox proxy object close methods can now be called multiple
times without error.
- Issue #11767: Correct file descriptor leak in mailbox'
s
__getitem__
method
.
-
Issue
#
12133
:
AbstractHTTPHandler
.
do_open
()
of
urllib
.
request
closes
the
HTTP
...
...
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