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
277640af
Kaydet (Commit)
277640af
authored
Eki 17, 2015
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Closes #25411: Improved Unicode support in SMTPHandler.
üst
4de9dae5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
handlers.py
Lib/logging/handlers.py
+12
-10
test_logging.py
Lib/test/test_logging.py
+2
-2
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/logging/handlers.py
Dosyayı görüntüle @
277640af
# Copyright 2001-201
3
by Vinay Sajip. All Rights Reserved.
# Copyright 2001-201
5
by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
...
...
@@ -18,7 +18,7 @@
Additional handlers for the logging package for Python. The core package is
based on PEP 282 and comments thereto in comp.lang.python.
Copyright (C) 2001-201
3
Vinay Sajip. All Rights Reserved.
Copyright (C) 2001-201
5
Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away!
"""
...
...
@@ -965,24 +965,26 @@ class SMTPHandler(logging.Handler):
"""
try
:
import
smtplib
from
email.utils
import
formatdate
from
email.message
import
EmailMessage
import
email.utils
port
=
self
.
mailport
if
not
port
:
port
=
smtplib
.
SMTP_PORT
smtp
=
smtplib
.
SMTP
(
self
.
mailhost
,
port
,
timeout
=
self
.
timeout
)
msg
=
self
.
format
(
record
)
msg
=
"From:
%
s
\r\n
To:
%
s
\r\n
Subject:
%
s
\r\n
Date:
%
s
\r\n\r\n
%
s"
%
(
self
.
fromaddr
,
","
.
join
(
self
.
toaddrs
),
self
.
getSubject
(
record
),
formatdate
(),
msg
)
msg
=
EmailMessage
(
)
msg
[
'From'
]
=
self
.
fromaddr
msg
[
'To'
]
=
','
.
join
(
self
.
toaddrs
)
msg
[
'Subject'
]
=
self
.
getSubject
(
record
)
msg
[
'Date'
]
=
email
.
utils
.
localtime
()
msg
.
set_content
(
self
.
format
(
record
)
)
if
self
.
username
:
if
self
.
secure
is
not
None
:
smtp
.
ehlo
()
smtp
.
starttls
(
*
self
.
secure
)
smtp
.
ehlo
()
smtp
.
login
(
self
.
username
,
self
.
password
)
smtp
.
send
mail
(
self
.
fromaddr
,
self
.
toaddrs
,
msg
)
smtp
.
send
_message
(
msg
)
smtp
.
quit
()
except
Exception
:
self
.
handleError
(
record
)
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
277640af
...
...
@@ -935,7 +935,7 @@ class SMTPHandlerTest(BaseTest):
timeout
=
self
.
TIMEOUT
)
self
.
assertEqual
(
h
.
toaddrs
,
[
'you'
])
self
.
messages
=
[]
r
=
logging
.
makeLogRecord
({
'msg'
:
'Hello'
})
r
=
logging
.
makeLogRecord
({
'msg'
:
'Hello
\u2713
'
})
self
.
handled
=
threading
.
Event
()
h
.
handle
(
r
)
self
.
handled
.
wait
(
self
.
TIMEOUT
)
# 14314: don't wait forever
...
...
@@ -946,7 +946,7 @@ class SMTPHandlerTest(BaseTest):
self
.
assertEqual
(
mailfrom
,
'me'
)
self
.
assertEqual
(
rcpttos
,
[
'you'
])
self
.
assertIn
(
'
\n
Subject: Log
\n
'
,
data
)
self
.
assertTrue
(
data
.
endswith
(
'
\n\n
Hello'
))
self
.
assertTrue
(
data
.
endswith
(
'
\n\n
Hello
\u2713
'
))
h
.
close
()
def
process_message
(
self
,
*
args
):
...
...
Misc/NEWS
Dosyayı görüntüle @
277640af
...
...
@@ -96,6 +96,9 @@ Core and Builtins
Library
-------
- Issue #25411: Improved Unicode support in SMTPHandler through better use of
the email package. Thanks to user simon04 for the patch.
- Issue #25380: Fixed protocol for the STACK_GLOBAL opcode in
pickletools.opcodes.
...
...
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