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
c9b4e606
Kaydet (Commit)
c9b4e606
authored
Şub 09, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge: #16564: Fix regression in use of encoders.encode_noop with binary data.
üst
633a92ff
6cb1d67e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
0 deletions
+28
-0
encoders.py
Lib/email/encoders.py
+6
-0
generator.py
Lib/email/generator.py
+3
-0
test_email.py
Lib/test/test_email/test_email.py
+16
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/email/encoders.py
Dosyayı görüntüle @
c9b4e606
...
...
@@ -76,3 +76,9 @@ def encode_7or8bit(msg):
def
encode_noop
(
msg
):
"""Do nothing."""
# Well, not quite *nothing*: in Python3 we have to turn bytes into a string
# in our internal surrogateescaped form in order to keep the model
# consistent.
orig
=
msg
.
get_payload
()
if
not
isinstance
(
orig
,
str
):
msg
.
set_payload
(
orig
.
decode
(
'ascii'
,
'surrogateescape'
))
Lib/email/generator.py
Dosyayı görüntüle @
c9b4e606
...
...
@@ -406,6 +406,9 @@ class BytesGenerator(Generator):
else
:
super
(
BytesGenerator
,
self
)
.
_handle_text
(
msg
)
# Default body handler
_writeBody
=
_handle_text
@classmethod
def
_compile_re
(
cls
,
s
,
flags
):
return
re
.
compile
(
s
.
encode
(
'ascii'
),
flags
)
...
...
Lib/test/test_email/test_email.py
Dosyayı görüntüle @
c9b4e606
...
...
@@ -1440,6 +1440,22 @@ class TestMIMEApplication(unittest.TestCase):
eq
(
msg
.
get_payload
()
.
strip
(),
'+vv8/f7/'
)
eq
(
msg
.
get_payload
(
decode
=
True
),
bytesdata
)
def
test_body_with_encode_noop
(
self
):
# Issue 16564: This does not produce an RFC valid message, since to be
# valid it should have a CTE of binary. But the below works in
# Python2, and is documented as working this way.
bytesdata
=
b
'
\xfa\xfb\xfc\xfd\xfe\xff
'
msg
=
MIMEApplication
(
bytesdata
,
_encoder
=
encoders
.
encode_noop
)
# Treated as a string, this will be invalid code points.
self
.
assertEqual
(
msg
.
get_payload
(),
'
\uFFFD
'
*
len
(
bytesdata
))
self
.
assertEqual
(
msg
.
get_payload
(
decode
=
True
),
bytesdata
)
s
=
BytesIO
()
g
=
BytesGenerator
(
s
)
g
.
flatten
(
msg
)
wireform
=
s
.
getvalue
()
msg2
=
email
.
message_from_bytes
(
wireform
)
self
.
assertEqual
(
msg
.
get_payload
(),
'
\uFFFD
'
*
len
(
bytesdata
))
self
.
assertEqual
(
msg2
.
get_payload
(
decode
=
True
),
bytesdata
)
# Test the basic MIMEText class
...
...
Misc/NEWS
Dosyayı görüntüle @
c9b4e606
...
...
@@ -241,6 +241,9 @@ Core and Builtins
Library
-------
-
Issue
#
16564
:
Fixed
regression
relative
to
Python2
in
the
operation
of
email
.
encoders
.
encode_noop
when
used
with
binary
data
.
-
Issue
#
10355
:
In
SpooledTemporaryFile
class
mode
,
name
,
encoding
and
newlines
properties
now
work
for
unrolled
files
.
Obsoleted
and
never
working
on
Python
3
xreadline
method
now
removed
.
...
...
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