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
b364bfe2
Kaydet (Commit)
b364bfe2
authored
Mar 22, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
close the file even if an exception occurs #5536
üst
8ed25205
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
35 deletions
+42
-35
urllib.py
Lib/urllib.py
+39
-35
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/urllib.py
Dosyayı görüntüle @
b364bfe2
...
...
@@ -233,41 +233,45 @@ class URLopener:
except
IOError
,
msg
:
pass
fp
=
self
.
open
(
url
,
data
)
headers
=
fp
.
info
()
if
filename
:
tfp
=
open
(
filename
,
'wb'
)
else
:
import
tempfile
garbage
,
path
=
splittype
(
url
)
garbage
,
path
=
splithost
(
path
or
""
)
path
,
garbage
=
splitquery
(
path
or
""
)
path
,
garbage
=
splitattr
(
path
or
""
)
suffix
=
os
.
path
.
splitext
(
path
)[
1
]
(
fd
,
filename
)
=
tempfile
.
mkstemp
(
suffix
)
self
.
__tempfiles
.
append
(
filename
)
tfp
=
os
.
fdopen
(
fd
,
'wb'
)
result
=
filename
,
headers
if
self
.
tempcache
is
not
None
:
self
.
tempcache
[
url
]
=
result
bs
=
1024
*
8
size
=
-
1
read
=
0
blocknum
=
0
if
reporthook
:
if
"content-length"
in
headers
:
size
=
int
(
headers
[
"Content-Length"
])
reporthook
(
blocknum
,
bs
,
size
)
while
1
:
block
=
fp
.
read
(
bs
)
if
block
==
""
:
break
read
+=
len
(
block
)
tfp
.
write
(
block
)
blocknum
+=
1
if
reporthook
:
reporthook
(
blocknum
,
bs
,
size
)
fp
.
close
()
tfp
.
close
()
try
:
headers
=
fp
.
info
()
if
filename
:
tfp
=
open
(
filename
,
'wb'
)
else
:
import
tempfile
garbage
,
path
=
splittype
(
url
)
garbage
,
path
=
splithost
(
path
or
""
)
path
,
garbage
=
splitquery
(
path
or
""
)
path
,
garbage
=
splitattr
(
path
or
""
)
suffix
=
os
.
path
.
splitext
(
path
)[
1
]
(
fd
,
filename
)
=
tempfile
.
mkstemp
(
suffix
)
self
.
__tempfiles
.
append
(
filename
)
tfp
=
os
.
fdopen
(
fd
,
'wb'
)
try
:
result
=
filename
,
headers
if
self
.
tempcache
is
not
None
:
self
.
tempcache
[
url
]
=
result
bs
=
1024
*
8
size
=
-
1
read
=
0
blocknum
=
0
if
reporthook
:
if
"content-length"
in
headers
:
size
=
int
(
headers
[
"Content-Length"
])
reporthook
(
blocknum
,
bs
,
size
)
while
1
:
block
=
fp
.
read
(
bs
)
if
block
==
""
:
break
read
+=
len
(
block
)
tfp
.
write
(
block
)
blocknum
+=
1
if
reporthook
:
reporthook
(
blocknum
,
bs
,
size
)
finally
:
tfp
.
close
()
finally
:
fp
.
close
()
del
fp
del
tfp
...
...
Misc/NEWS
Dosyayı görüntüle @
b364bfe2
...
...
@@ -188,6 +188,9 @@ Core and Builtins
Library
-------
- Issue #5536: urllib.urlretrieve makes sure to close the file it's writing to
even if an exception occurs.
- Issue #5381: Added object_pairs_hook to the json module. This allows
OrderedDicts to be built by the decoder.
...
...
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