summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/logging/handlers.py10
-rw-r--r--Misc/NEWS2
2 files changed, 12 insertions, 0 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index bdf82af..d752063 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -31,6 +31,11 @@ try:
import codecs
except ImportError:
codecs = None
+try:
+ unicode
+ _unicode = True
+except NameError:
+ _unicode = False
#
# Some constants...
@@ -779,6 +784,11 @@ class SysLogHandler(logging.Handler):
self.encodePriority(self.facility,
self.mapPriority(record.levelname)),
msg)
+ # Treat unicode messages as required by RFC 5424
+ if _unicode and type(msg) is unicode:
+ msg = msg.encode('utf-8')
+ if codecs:
+ msg = codecs.BOM_UTF8 + msg
try:
if self.unixsocket:
try:
diff --git a/Misc/NEWS b/Misc/NEWS
index 49c739f..6946706 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -418,6 +418,8 @@ Core and Builtins
Library
-------
+- Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424.
+
- Issue #7099: Decimal.is_normal now returns True for numbers with exponent
larger than emax.