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
8cbd3df3
Kaydet (Commit)
8cbd3df3
authored
Ara 21, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28992: Use bytes.fromhex().
üst
47bdc403
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
10 deletions
+7
-10
_encoded_words.py
Lib/email/_encoded_words.py
+1
-1
multibytecodec_support.py
Lib/test/multibytecodec_support.py
+1
-1
test_unicode.py
Lib/test/test_unicode.py
+4
-7
parse.py
Lib/urllib/parse.py
+1
-1
No files found.
Lib/email/_encoded_words.py
Dosyayı görüntüle @
8cbd3df3
...
...
@@ -62,7 +62,7 @@ __all__ = ['decode_q',
# regex based decoder.
_q_byte_subber
=
functools
.
partial
(
re
.
compile
(
br
'=([a-fA-F0-9]{2})'
)
.
sub
,
lambda
m
:
bytes
([
int
(
m
.
group
(
1
),
16
)]
))
lambda
m
:
bytes
.
fromhex
(
m
.
group
(
1
)
))
def
decode_q
(
encoded
):
encoded
=
encoded
.
replace
(
b
'_'
,
b
' '
)
...
...
Lib/test/multibytecodec_support.py
Dosyayı görüntüle @
8cbd3df3
...
...
@@ -338,7 +338,7 @@ class TestBase_Mapping(unittest.TestCase):
uc
=
re
.
findall
(
'<a u="([A-F0-9]{4})" b="([0-9A-F ]+)"/>'
,
ucmdata
)
for
uni
,
coded
in
uc
:
unich
=
chr
(
int
(
uni
,
16
))
codech
=
bytes
(
int
(
c
,
16
)
for
c
in
coded
.
split
()
)
codech
=
bytes
.
fromhex
(
coded
)
self
.
_testpoint
(
codech
,
unich
)
def
test_mapping_supplemental
(
self
):
...
...
Lib/test/test_unicode.py
Dosyayı görüntüle @
8cbd3df3
...
...
@@ -1793,9 +1793,6 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
seq
.
decode
(
'utf-8'
,
'ignore'
),
res
.
replace
(
'
\uFFFD
'
,
''
))
def
to_bytestring
(
self
,
seq
):
return
bytes
(
int
(
c
,
16
)
for
c
in
seq
.
split
())
def
assertCorrectUTF8Decoding
(
self
,
seq
,
res
,
err
):
"""
Check that an invalid UTF-8 sequence raises a UnicodeDecodeError when
...
...
@@ -1851,7 +1848,7 @@ class UnicodeTest(string_tests.CommonTest,
]
FFFD
=
'
\ufffd
'
for
seq
in
sequences
:
self
.
assertCorrectUTF8Decoding
(
self
.
to_bytestring
(
seq
),
'
\ufffd
'
,
self
.
assertCorrectUTF8Decoding
(
bytes
.
fromhex
(
seq
),
'
\ufffd
'
,
'unexpected end of data'
)
def
test_invalid_cb_for_2bytes_seq
(
self
):
...
...
@@ -1873,7 +1870,7 @@ class UnicodeTest(string_tests.CommonTest,
(
'DF C0'
,
FFFDx2
),
(
'DF FF'
,
FFFDx2
),
]
for
seq
,
res
in
sequences
:
self
.
assertCorrectUTF8Decoding
(
self
.
to_bytestring
(
seq
),
res
,
self
.
assertCorrectUTF8Decoding
(
bytes
.
fromhex
(
seq
),
res
,
'invalid continuation byte'
)
def
test_invalid_cb_for_3bytes_seq
(
self
):
...
...
@@ -1931,7 +1928,7 @@ class UnicodeTest(string_tests.CommonTest,
(
'EF BF C0'
,
FFFDx2
),
(
'EF BF FF'
,
FFFDx2
),
]
for
seq
,
res
in
sequences
:
self
.
assertCorrectUTF8Decoding
(
self
.
to_bytestring
(
seq
),
res
,
self
.
assertCorrectUTF8Decoding
(
bytes
.
fromhex
(
seq
),
res
,
'invalid continuation byte'
)
def
test_invalid_cb_for_4bytes_seq
(
self
):
...
...
@@ -2010,7 +2007,7 @@ class UnicodeTest(string_tests.CommonTest,
(
'F4 8F BF C0'
,
FFFDx2
),
(
'F4 8F BF FF'
,
FFFDx2
)
]
for
seq
,
res
in
sequences
:
self
.
assertCorrectUTF8Decoding
(
self
.
to_bytestring
(
seq
),
res
,
self
.
assertCorrectUTF8Decoding
(
bytes
.
fromhex
(
seq
),
res
,
'invalid continuation byte'
)
def
test_codecs_idna
(
self
):
...
...
Lib/urllib/parse.py
Dosyayı görüntüle @
8cbd3df3
...
...
@@ -574,7 +574,7 @@ def unquote_to_bytes(string):
# if the function is never called
global
_hextobyte
if
_hextobyte
is
None
:
_hextobyte
=
{(
a
+
b
)
.
encode
():
bytes
([
int
(
a
+
b
,
16
)]
)
_hextobyte
=
{(
a
+
b
)
.
encode
():
bytes
.
fromhex
(
a
+
b
)
for
a
in
_hexdig
for
b
in
_hexdig
}
for
item
in
bits
[
1
:]:
try
:
...
...
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