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
326b5ab0
Kaydet (Commit)
326b5ab0
authored
Ock 18, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20270: urllib and urlparse now support empty ports.
üst
7a278da4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
12 deletions
+48
-12
test_urllib.py
Lib/test/test_urllib.py
+20
-0
test_urlparse.py
Lib/test/test_urlparse.py
+10
-0
urllib.py
Lib/urllib.py
+11
-8
urlparse.py
Lib/urlparse.py
+5
-4
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_urllib.py
Dosyayı görüntüle @
326b5ab0
...
@@ -789,6 +789,26 @@ class Utility_Tests(unittest.TestCase):
...
@@ -789,6 +789,26 @@ class Utility_Tests(unittest.TestCase):
self
.
assertEqual
((
'user 2'
,
'ab'
),
urllib
.
splitpasswd
(
'user 2:ab'
))
self
.
assertEqual
((
'user 2'
,
'ab'
),
urllib
.
splitpasswd
(
'user 2:ab'
))
self
.
assertEqual
((
'user+1'
,
'a+b'
),
urllib
.
splitpasswd
(
'user+1:a+b'
))
self
.
assertEqual
((
'user+1'
,
'a+b'
),
urllib
.
splitpasswd
(
'user+1:a+b'
))
def
test_splitport
(
self
):
splitport
=
urllib
.
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
):
splitnport
=
urllib
.
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
))
class
URLopener_Tests
(
unittest
.
TestCase
):
class
URLopener_Tests
(
unittest
.
TestCase
):
"""Testcase to test the open method of URLopener class."""
"""Testcase to test the open method of URLopener class."""
...
...
Lib/test/test_urlparse.py
Dosyayı görüntüle @
326b5ab0
...
@@ -362,6 +362,16 @@ class UrlParseTestCase(unittest.TestCase):
...
@@ -362,6 +362,16 @@ class UrlParseTestCase(unittest.TestCase):
(
'http://[::12.34.56.78]/foo/'
,
'::12.34.56.78'
,
None
),
(
'http://[::12.34.56.78]/foo/'
,
'::12.34.56.78'
,
None
),
(
'http://[::ffff:12.34.56.78]/foo/'
,
(
'http://[::ffff:12.34.56.78]/foo/'
,
'::ffff:12.34.56.78'
,
None
),
'::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
),
]:
]:
urlparsed
=
urlparse
.
urlparse
(
url
)
urlparsed
=
urlparse
.
urlparse
(
url
)
self
.
assertEqual
((
urlparsed
.
hostname
,
urlparsed
.
port
)
,
(
hostname
,
port
))
self
.
assertEqual
((
urlparsed
.
hostname
,
urlparsed
.
port
)
,
(
hostname
,
port
))
...
...
Lib/urllib.py
Dosyayı görüntüle @
326b5ab0
...
@@ -1125,10 +1125,13 @@ def splitport(host):
...
@@ -1125,10 +1125,13 @@ def splitport(host):
global
_portprog
global
_portprog
if
_portprog
is
None
:
if
_portprog
is
None
:
import
re
import
re
_portprog
=
re
.
compile
(
'^(.*):([0-9]
+
)$'
)
_portprog
=
re
.
compile
(
'^(.*):([0-9]
*
)$'
)
match
=
_portprog
.
match
(
host
)
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
return
host
,
None
_nportprog
=
None
_nportprog
=
None
...
@@ -1145,12 +1148,12 @@ def splitnport(host, defport=-1):
...
@@ -1145,12 +1148,12 @@ def splitnport(host, defport=-1):
match
=
_nportprog
.
match
(
host
)
match
=
_nportprog
.
match
(
host
)
if
match
:
if
match
:
host
,
port
=
match
.
group
(
1
,
2
)
host
,
port
=
match
.
group
(
1
,
2
)
try
:
if
port
:
if
not
port
:
raise
ValueError
,
"no digits"
try
:
nport
=
int
(
port
)
nport
=
int
(
port
)
except
ValueError
:
except
ValueError
:
nport
=
None
nport
=
None
return
host
,
nport
return
host
,
nport
return
host
,
defport
return
host
,
defport
_queryprog
=
None
_queryprog
=
None
...
...
Lib/urlparse.py
Dosyayı görüntüle @
326b5ab0
...
@@ -109,10 +109,11 @@ class ResultMixin(object):
...
@@ -109,10 +109,11 @@ class ResultMixin(object):
netloc
=
self
.
netloc
.
split
(
'@'
)[
-
1
]
.
split
(
']'
)[
-
1
]
netloc
=
self
.
netloc
.
split
(
'@'
)[
-
1
]
.
split
(
']'
)[
-
1
]
if
':'
in
netloc
:
if
':'
in
netloc
:
port
=
netloc
.
split
(
':'
)[
1
]
port
=
netloc
.
split
(
':'
)[
1
]
port
=
int
(
port
,
10
)
if
port
:
# verify legal port
port
=
int
(
port
,
10
)
if
(
0
<=
port
<=
65535
):
# verify legal port
return
port
if
(
0
<=
port
<=
65535
):
return
port
return
None
return
None
from
collections
import
namedtuple
from
collections
import
namedtuple
...
...
Misc/NEWS
Dosyayı görüntüle @
326b5ab0
...
@@ -35,6 +35,8 @@ Core and Builtins
...
@@ -35,6 +35,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #20270: urllib and urlparse now support empty ports.
- Issue #20243: TarFile no longer raise ReadError when opened in write mode.
- Issue #20243: TarFile no longer raise ReadError when opened in write mode.
- Issue #20245: The open functions in the tarfile module now correctly handle
- Issue #20245: The open functions in the tarfile module now correctly handle
...
...
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