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
5d83d1a8
Kaydet (Commit)
5d83d1a8
authored
Ock 18, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #20270: urllib.urlparse now supports empty ports.
üst
2d1f0924
ff97b08d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
24 deletions
+47
-24
test_urlparse.py
Lib/test/test_urlparse.py
+28
-10
parse.py
Lib/urllib/parse.py
+17
-14
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_urlparse.py
Dosyayı görüntüle @
5d83d1a8
...
...
@@ -394,6 +394,16 @@ class UrlParseTestCase(unittest.TestCase):
(
'http://[::12.34.56.78]/foo/'
,
'::12.34.56.78'
,
None
),
(
'http://[::ffff:12.34.56.78]/foo/'
,
'::ffff:12.34.56.78'
,
None
),
(
'http://Test.python.org:/foo/'
,
'test.python.org'
,
None
),
(
'http://12.34.56.78:/foo/'
,
'12.34.56.78'
,
None
),
(
'http://[::1]:/foo/'
,
'::1'
,
None
),
(
'http://[dead:beef::1]:/foo/'
,
'dead:beef::1'
,
None
),
(
'http://[dead:beef::]:/foo/'
,
'dead:beef::'
,
None
),
(
'http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:/foo/'
,
'dead:beef:cafe:5417:affe:8fa3:deaf:feed'
,
None
),
(
'http://[::12.34.56.78]:/foo/'
,
'::12.34.56.78'
,
None
),
(
'http://[::ffff:12.34.56.78]:/foo/'
,
'::ffff:12.34.56.78'
,
None
),
]
def
_encode
(
t
):
return
t
[
0
]
.
encode
(
'ascii'
),
t
[
1
]
.
encode
(
'ascii'
),
t
[
2
]
...
...
@@ -739,17 +749,25 @@ class UrlParseTestCase(unittest.TestCase):
errors
=
"ignore"
)
self
.
assertEqual
(
result
,
[(
'key'
,
'
\u0141
-'
)])
def
test_splitport
(
self
):
splitport
=
urllib
.
parse
.
splitport
self
.
assertEqual
(
splitport
(
'parrot:88'
),
(
'parrot'
,
'88'
))
self
.
assertEqual
(
splitport
(
'parrot'
),
(
'parrot'
,
None
))
self
.
assertEqual
(
splitport
(
'parrot:'
),
(
'parrot'
,
None
))
self
.
assertEqual
(
splitport
(
'127.0.0.1'
),
(
'127.0.0.1'
,
None
))
self
.
assertEqual
(
splitport
(
'parrot:cheese'
),
(
'parrot:cheese'
,
None
))
def
test_splitnport
(
self
):
# Normal cases are exercised by other tests; ensure that we also
# catch cases with no port specified. (testcase ensuring coverage
)
result
=
urllib
.
parse
.
splitnport
(
'parrot:88'
)
self
.
assertEqual
(
result
,
(
'parrot'
,
88
))
result
=
urllib
.
parse
.
splitnport
(
'parrot'
)
self
.
assertEqual
(
result
,
(
'parrot'
,
-
1
))
result
=
urllib
.
parse
.
splitnport
(
'parrot'
,
55
)
self
.
assertEqual
(
result
,
(
'parrot
'
,
55
))
result
=
urllib
.
parse
.
splitnport
(
'parrot:'
)
self
.
assertEqual
(
result
,
(
'parrot'
,
None
))
splitnport
=
urllib
.
parse
.
splitnport
self
.
assertEqual
(
splitnport
(
'parrot:88'
),
(
'parrot'
,
88
)
)
self
.
assertEqual
(
splitnport
(
'parrot'
),
(
'parrot'
,
-
1
)
)
self
.
assertEqual
(
splitnport
(
'parrot'
,
55
),
(
'parrot'
,
55
))
self
.
assertEqual
(
splitnport
(
'parrot:'
),
(
'parrot'
,
-
1
)
)
self
.
assertEqual
(
splitnport
(
'parrot:'
,
55
),
(
'parrot'
,
55
))
self
.
assertEqual
(
splitnport
(
'127.0.0.1'
),
(
'127.0.0.1'
,
-
1
)
)
self
.
assertEqual
(
splitnport
(
'127.0.0.1'
,
55
),
(
'127.0.0.1
'
,
55
))
self
.
assertEqual
(
splitnport
(
'parrot:cheese'
),
(
'parrot'
,
None
)
)
self
.
assertEqual
(
splitnport
(
'parrot:cheese'
,
55
)
,
(
'parrot'
,
None
))
def
test_splitquery
(
self
):
# Normal cases are exercised by other tests; ensure that we also
...
...
Lib/urllib/parse.py
Dosyayı görüntüle @
5d83d1a8
...
...
@@ -182,10 +182,10 @@ class _NetlocResultMixinStr(_NetlocResultMixinBase, _ResultMixinStr):
_
,
have_open_br
,
bracketed
=
hostinfo
.
partition
(
'['
)
if
have_open_br
:
hostname
,
_
,
port
=
bracketed
.
partition
(
']'
)
_
,
have_port
,
port
=
port
.
partition
(
':'
)
_
,
_
,
port
=
port
.
partition
(
':'
)
else
:
hostname
,
have_port
,
port
=
hostinfo
.
partition
(
':'
)
if
not
have_
port
:
hostname
,
_
,
port
=
hostinfo
.
partition
(
':'
)
if
not
port
:
port
=
None
return
hostname
,
port
...
...
@@ -212,10 +212,10 @@ class _NetlocResultMixinBytes(_NetlocResultMixinBase, _ResultMixinBytes):
_
,
have_open_br
,
bracketed
=
hostinfo
.
partition
(
b
'['
)
if
have_open_br
:
hostname
,
_
,
port
=
bracketed
.
partition
(
b
']'
)
_
,
have_port
,
port
=
port
.
partition
(
b
':'
)
_
,
_
,
port
=
port
.
partition
(
b
':'
)
else
:
hostname
,
have_port
,
port
=
hostinfo
.
partition
(
b
':'
)
if
not
have_
port
:
hostname
,
_
,
port
=
hostinfo
.
partition
(
b
':'
)
if
not
port
:
port
=
None
return
hostname
,
port
...
...
@@ -898,10 +898,13 @@ def splitport(host):
"""splitport('host:port') --> 'host', 'port'."""
global
_portprog
if
_portprog
is
None
:
_portprog
=
re
.
compile
(
'^(.*):([0-9]
+
)$'
)
_portprog
=
re
.
compile
(
'^(.*):([0-9]
*
)$'
)
match
=
_portprog
.
match
(
host
)
if
match
:
return
match
.
group
(
1
,
2
)
if
match
:
host
,
port
=
match
.
groups
()
if
port
:
return
host
,
port
return
host
,
None
_nportprog
=
None
...
...
@@ -917,12 +920,12 @@ def splitnport(host, defport=-1):
match
=
_nportprog
.
match
(
host
)
if
match
:
host
,
port
=
match
.
group
(
1
,
2
)
try
:
if
not
port
:
raise
ValueError
(
"no digits"
)
nport
=
int
(
port
)
except
ValueError
:
nport
=
None
return
host
,
nport
if
port
:
try
:
nport
=
int
(
port
)
except
ValueError
:
nport
=
None
return
host
,
nport
return
host
,
defport
_queryprog
=
None
...
...
Misc/NEWS
Dosyayı görüntüle @
5d83d1a8
...
...
@@ -25,6 +25,8 @@ Core and Builtins
Library
-------
- Issue #20270: urllib.urlparse now supports empty ports.
- Issue #20243: TarFile no longer raise ReadError when opened in write mode.
- Issue #20238: TarFile opened with external fileobj and "w:gz" mode didn'
t
...
...
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