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
a6023ca3
Kaydet (Commit)
a6023ca3
authored
Nis 16, 2010
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Reverting the previous checkin (80103). The feature should not have been merged to 3.1 maint.
üst
2176ad5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
57 deletions
+12
-57
test_urlparse.py
Lib/test/test_urlparse.py
+0
-34
parse.py
Lib/urllib/parse.py
+12
-20
NEWS
Misc/NEWS
+0
-3
No files found.
Lib/test/test_urlparse.py
Dosyayı görüntüle @
a6023ca3
...
...
@@ -239,44 +239,10 @@ class UrlParseTestCase(unittest.TestCase):
#self.checkJoin(RFC2396_BASE, '?y', 'http://a/b/c/?y')
#self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x')
def
test_RFC3986
(
self
):
self
.
checkJoin
(
RFC3986_BASE
,
'?y'
,
'http://a/b/c/d;p?y'
)
self
.
checkJoin
(
RFC2396_BASE
,
';x'
,
'http://a/b/c/;x'
)
def
test_RFC2732
(
self
):
for
url
,
hostname
,
port
in
[
(
'http://Test.python.org:5432/foo/'
,
'test.python.org'
,
5432
),
(
'http://12.34.56.78:5432/foo/'
,
'12.34.56.78'
,
5432
),
(
'http://[::1]:5432/foo/'
,
'::1'
,
5432
),
(
'http://[dead:beef::1]:5432/foo/'
,
'dead:beef::1'
,
5432
),
(
'http://[dead:beef::]:5432/foo/'
,
'dead:beef::'
,
5432
),
(
'http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]:5432/foo/'
,
'dead:beef:cafe:5417:affe:8fa3:deaf:feed'
,
5432
),
(
'http://[::12.34.56.78]:5432/foo/'
,
'::12.34.56.78'
,
5432
),
(
'http://[::ffff:12.34.56.78]:5432/foo/'
,
'::ffff:12.34.56.78'
,
5432
),
(
'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
=
urllib
.
parse
.
urlparse
(
url
)
self
.
assertEqual
((
urlparsed
.
hostname
,
urlparsed
.
port
)
,
(
hostname
,
port
))
for
invalid_url
in
[
'http://::12.34.56.78]/'
,
'http://[::1/foo/'
,
'http://[::ffff:12.34.56.78'
]:
self
.
assertRaises
(
ValueError
,
lambda
:
urllib
.
parse
.
urlparse
(
invalid_url
)
.
hostname
)
self
.
assertRaises
(
ValueError
,
lambda
:
urllib
.
parse
.
urlparse
(
invalid_url
))
def
test_urldefrag
(
self
):
for
url
,
defrag
,
frag
in
[
(
'http://python.org#frag'
,
'http://python.org'
,
'frag'
),
...
...
Lib/urllib/parse.py
Dosyayı görüntüle @
a6023ca3
...
...
@@ -69,26 +69,22 @@ class ResultMixin(object):
@property
def
hostname
(
self
):
netloc
=
self
.
netloc
.
split
(
'@'
)[
-
1
]
if
'['
in
netloc
and
']'
in
netloc
:
return
netloc
.
split
(
']'
)[
0
][
1
:]
.
lower
()
elif
'['
in
netloc
or
']'
in
netloc
:
raise
ValueError
(
"Invalid IPv6 hostname"
)
elif
':'
in
netloc
:
return
netloc
.
split
(
':'
)[
0
]
.
lower
()
elif
netloc
==
''
:
return
None
else
:
return
netloc
.
lower
()
netloc
=
self
.
netloc
if
"@"
in
netloc
:
netloc
=
netloc
.
rsplit
(
"@"
,
1
)[
1
]
if
":"
in
netloc
:
netloc
=
netloc
.
split
(
":"
,
1
)[
0
]
return
netloc
.
lower
()
or
None
@property
def
port
(
self
):
netloc
=
self
.
netloc
.
split
(
'@'
)[
-
1
]
.
split
(
']'
)[
-
1
]
if
':'
in
netloc
:
port
=
netloc
.
split
(
':'
)[
1
]
netloc
=
self
.
netloc
if
"@"
in
netloc
:
netloc
=
netloc
.
rsplit
(
"@"
,
1
)[
1
]
if
":"
in
netloc
:
port
=
netloc
.
split
(
":"
,
1
)[
1
]
return
int
(
port
,
10
)
else
:
return
None
return
None
from
collections
import
namedtuple
...
...
@@ -133,10 +129,6 @@ def _splitparams(url):
def
_splitnetloc
(
url
,
start
=
0
):
delim
=
len
(
url
)
# position of end of domain part of url, default is end
if
'['
in
url
:
# check for invalid IPv6 URL
if
not
']'
in
url
:
raise
ValueError
(
"Invalid IPv6 URL"
)
elif
']'
in
url
:
if
not
'['
in
url
:
raise
ValueError
(
"Invalid IPv6 URL"
)
for
c
in
'/?#'
:
# look for delimiters; the order is NOT important
wdelim
=
url
.
find
(
c
,
start
)
# find first of this delim
if
wdelim
>=
0
:
# if found
...
...
Misc/NEWS
Dosyayı görüntüle @
a6023ca3
...
...
@@ -28,9 +28,6 @@ Core and Builtins
Library
-------
- Issue #2987: RFC2732 support for urlparse (IPv6 addresses). Patch by Tony
Locke and Hans Ulrich Niedermann.
- Issue #5277: Fix quote counting when parsing RFC 2231 encoded parameters.
- Issue #8383: pickle and pickletools use surrogatepass error handler when
...
...
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