summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2009-10-21 20:22:14 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2009-10-21 20:22:14 (GMT)
commit5ac6528b91382e218332d367c98f06a5ed8670ff (patch)
tree207e6aaed6af893d9e872ea972a3fb6f652c5d0b
parentcf842ad418fa2b4b820e9f15a69dc5dd04dbd546 (diff)
downloadcpython-5ac6528b91382e218332d367c98f06a5ed8670ff.zip
cpython-5ac6528b91382e218332d367c98f06a5ed8670ff.tar.gz
cpython-5ac6528b91382e218332d367c98f06a5ed8670ff.tar.bz2
Issue #7077: logging: SysLogHandler now treats Unicode as per RFC 5424.
-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.