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
a3643c28
Kaydet (Commit)
a3643c28
authored
Şub 06, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #12923: Merge FancyURLopener fix from 3.5
üst
ab8d4fba
a0370225
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
17 deletions
+42
-17
test_urllib.py
Lib/test/test_urllib.py
+25
-6
request.py
Lib/urllib/request.py
+13
-11
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib.py
Dosyayı görüntüle @
a3643c28
...
...
@@ -39,10 +39,7 @@ def urlopen(url, data=None, proxies=None):
if
proxies
is
not
None
:
opener
=
urllib
.
request
.
FancyURLopener
(
proxies
=
proxies
)
elif
not
_urlopener
:
with
support
.
check_warnings
(
(
'FancyURLopener style of invoking requests is deprecated.'
,
DeprecationWarning
)):
opener
=
urllib
.
request
.
FancyURLopener
()
opener
=
FancyURLopener
()
_urlopener
=
opener
else
:
opener
=
_urlopener
...
...
@@ -52,6 +49,13 @@ def urlopen(url, data=None, proxies=None):
return
opener
.
open
(
url
,
data
)
def
FancyURLopener
():
with
support
.
check_warnings
(
(
'FancyURLopener style of invoking requests is deprecated.'
,
DeprecationWarning
)):
return
urllib
.
request
.
FancyURLopener
()
def
fakehttp
(
fakedata
):
class
FakeSocket
(
io
.
BytesIO
):
io_refs
=
1
...
...
@@ -291,11 +295,26 @@ Connection: close
Content-Type: text/html; charset=iso-8859-1
'''
)
try
:
self
.
assertRaises
(
urllib
.
error
.
HTTPError
,
urlopen
,
"http://python.org/"
)
msg
=
"Redirection to url 'file:"
with
self
.
assertRaisesRegex
(
urllib
.
error
.
HTTPError
,
msg
):
urlopen
(
"http://python.org/"
)
finally
:
self
.
unfakehttp
()
def
test_redirect_limit_independent
(
self
):
# Ticket #12923: make sure independent requests each use their
# own retry limit.
for
i
in
range
(
FancyURLopener
()
.
maxtries
):
self
.
fakehttp
(
b
'''HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
'''
)
try
:
self
.
assertRaises
(
urllib
.
error
.
HTTPError
,
urlopen
,
"http://something"
)
finally
:
self
.
unfakehttp
()
def
test_empty_socket
(
self
):
# urlopen() raises OSError if the underlying socket does not send any
# data. (#1680230)
...
...
Lib/urllib/request.py
Dosyayı görüntüle @
a3643c28
...
...
@@ -2110,18 +2110,20 @@ class FancyURLopener(URLopener):
def
http_error_302
(
self
,
url
,
fp
,
errcode
,
errmsg
,
headers
,
data
=
None
):
"""Error 302 -- relocated (temporarily)."""
self
.
tries
+=
1
if
self
.
maxtries
and
self
.
tries
>=
self
.
maxtries
:
if
hasattr
(
self
,
"http_error_500"
):
meth
=
self
.
http_error_500
else
:
meth
=
self
.
http_error_default
try
:
if
self
.
maxtries
and
self
.
tries
>=
self
.
maxtries
:
if
hasattr
(
self
,
"http_error_500"
):
meth
=
self
.
http_error_500
else
:
meth
=
self
.
http_error_default
return
meth
(
url
,
fp
,
500
,
"Internal Server Error: Redirect Recursion"
,
headers
)
result
=
self
.
redirect_internal
(
url
,
fp
,
errcode
,
errmsg
,
headers
,
data
)
return
result
finally
:
self
.
tries
=
0
return
meth
(
url
,
fp
,
500
,
"Internal Server Error: Redirect Recursion"
,
headers
)
result
=
self
.
redirect_internal
(
url
,
fp
,
errcode
,
errmsg
,
headers
,
data
)
self
.
tries
=
0
return
result
def
redirect_internal
(
self
,
url
,
fp
,
errcode
,
errmsg
,
headers
,
data
):
if
'location'
in
headers
:
...
...
Misc/ACKS
Dosyayı görüntüle @
a3643c28
...
...
@@ -1218,6 +1218,7 @@ Ben Roberts
Mark Roberts
Andy Robinson
Jim Robinson
Daniel Rocco
Mark Roddy
Kevin Rodgers
Sean Rodman
...
...
Misc/NEWS
Dosyayı görüntüle @
a3643c28
...
...
@@ -169,6 +169,9 @@ Core and Builtins
Library
-------
-
Issue
#
12923
:
Reset
FancyURLopener
's redirect counter even if there is an
exception. Based on patches by Brian Brazil and Daniel Rocco.
- Issue #25945: Fixed a crash when unpickle the functools.partial object with
wrong state. Fixed a leak in failed functools.partial constructor.
"args" and "keywords" attributes of functools.partial have now always types
...
...
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