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
0d8e16c7
Kaydet (Commit)
0d8e16c7
authored
Agu 05, 2003
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Support trailing dots in DNS names. Fixes #782510. Will backport to 2.3.
üst
8db4403a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
idna.py
Lib/encodings/idna.py
+15
-3
test_unicode.py
Lib/test/test_unicode.py
+4
-0
No files found.
Lib/encodings/idna.py
Dosyayı görüntüle @
0d8e16c7
...
...
@@ -150,10 +150,16 @@ class Codec(codecs.Codec):
raise
UnicodeError
,
"unsupported error handling "
+
errors
result
=
[]
for
label
in
dots
.
split
(
input
):
labels
=
dots
.
split
(
input
)
if
labels
and
len
(
labels
[
-
1
])
==
0
:
trailing_dot
=
'.'
del
labels
[
-
1
]
else
:
trailing_dot
=
''
for
label
in
labels
:
result
.
append
(
ToASCII
(
label
))
# Join with U+002E
return
"."
.
join
(
result
),
len
(
input
)
return
"."
.
join
(
result
)
+
trailing_dot
,
len
(
input
)
def
decode
(
self
,
input
,
errors
=
'strict'
):
...
...
@@ -168,11 +174,17 @@ class Codec(codecs.Codec):
unicode
(
input
,
"ascii"
)
labels
=
input
.
split
(
"."
)
if
labels
and
len
(
labels
[
-
1
])
==
0
:
trailing_dot
=
u'.'
del
labels
[
-
1
]
else
:
trailing_dot
=
u''
result
=
[]
for
label
in
labels
:
result
.
append
(
ToUnicode
(
label
))
return
u"."
.
join
(
result
),
len
(
input
)
return
u"."
.
join
(
result
)
+
trailing_dot
,
len
(
input
)
class
StreamWriter
(
Codec
,
codecs
.
StreamWriter
):
pass
...
...
Lib/test/test_unicode.py
Dosyayı görüntüle @
0d8e16c7
...
...
@@ -524,6 +524,10 @@ class UnicodeTest(
# * strict decoding testing for all of the
# UTF8_ERROR cases in PyUnicode_DecodeUTF8
def
test_codecs_idna
(
self
):
# Test whether trailing dot is preserved
self
.
assertEqual
(
u"www.python.org."
.
encode
(
"idna"
),
"www.python.org."
)
def
test_codecs_errors
(
self
):
# Error handling (encoding)
self
.
assertRaises
(
UnicodeError
,
u'Andr
\202
x'
.
encode
,
'ascii'
)
...
...
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