[Python-checkins] cpython (3.2): Issue #12168: SysLogHandler now allows NUL termination to be controlled using a

vinay.sajip python-checkins at python.org
Thu Jun 9 17:55:33 CEST 2011


http://hg.python.org/cpython/rev/260b84851d1f
changeset:   70739:260b84851d1f
branch:      3.2
parent:      70736:d40609dd01e0
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Thu Jun 09 16:50:49 2011 +0100
summary:
  Issue #12168: SysLogHandler now allows NUL termination to be controlled using a new 'append_nul' attribute on the handler.

files:
  Lib/logging/handlers.py |  6 +++++-
  Misc/NEWS               |  3 +++
  2 files changed, 8 insertions(+), 1 deletions(-)


diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -766,6 +766,8 @@
         """
         return self.priority_map.get(levelName, "warning")
 
+    append_nul = True   # some old syslog daemons expect a NUL terminator
+
     def emit(self, record):
         """
         Emit a record.
@@ -773,7 +775,9 @@
         The record is formatted, and then sent to the syslog server. If
         exception information is present, it is NOT sent to the server.
         """
-        msg = self.format(record) + '\000'
+        msg = self.format(record)
+        if self.append_nul:
+            msg += '\000'
         """
         We need to convert record level to lowercase, maybe this will
         change in the future.
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,9 @@
 Library
 -------
 
+- Issue #12168: SysLogHandler now allows NUL termination to be controlled using
+  a new 'append_nul' attribute on the handler.
+
 - Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
   instead of os.stat.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list