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
775632ba
Kaydet (Commit)
775632ba
authored
Ara 13, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#19957: Simplify encode_7or8bit now that _payload is always str.
Patch by Vajrasky Kok, test enhancement by me.
üst
cd0cb8cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
encoders.py
Lib/email/encoders.py
+4
-13
test_email.py
Lib/test/test_email/test_email.py
+8
-1
No files found.
Lib/email/encoders.py
Dosyayı görüntüle @
775632ba
...
...
@@ -54,21 +54,12 @@ def encode_7or8bit(msg):
# There's no payload. For backwards compatibility we use 7bit
msg
[
'Content-Transfer-Encoding'
]
=
'7bit'
return
# We play a trick to make this go fast. If
encoding/decode to ASCII
#
succeeds,
we know the data must be 7bit, otherwise treat it as 8bit.
# We play a trick to make this go fast. If
decoding from ASCII succeeds,
# we know the data must be 7bit, otherwise treat it as 8bit.
try
:
if
isinstance
(
orig
,
str
):
orig
.
encode
(
'ascii'
)
else
:
orig
.
decode
(
'ascii'
)
orig
.
decode
(
'ascii'
)
except
UnicodeError
:
charset
=
msg
.
get_charset
()
output_cset
=
charset
and
charset
.
output_charset
# iso-2022-* is non-ASCII but encodes to a 7-bit representation
if
output_cset
and
output_cset
.
lower
()
.
startswith
(
'iso-2022-'
):
msg
[
'Content-Transfer-Encoding'
]
=
'7bit'
else
:
msg
[
'Content-Transfer-Encoding'
]
=
'8bit'
msg
[
'Content-Transfer-Encoding'
]
=
'8bit'
else
:
msg
[
'Content-Transfer-Encoding'
]
=
'7bit'
...
...
Lib/test/test_email/test_email.py
Dosyayı görüntüle @
775632ba
...
...
@@ -765,8 +765,15 @@ class TestEncoders(unittest.TestCase):
# whose output character set is 7bit gets a transfer-encoding
# of 7bit.
eq
=
self
.
assertEqual
msg
=
MIMEText
(
'文'
,
_charset
=
'euc-jp'
)
msg
=
MIMEText
(
'文
\n
'
,
_charset
=
'euc-jp'
)
eq
(
msg
[
'content-transfer-encoding'
],
'7bit'
)
eq
(
msg
.
as_string
(),
textwrap
.
dedent
(
"""
\
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit
\x1b
$BJ8
\x1b
(B
"""
))
def
test_qp_encode_latin1
(
self
):
msg
=
MIMEText
(
'
\xe1\xf6\n
'
,
'text'
,
'ISO-8859-1'
)
...
...
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