[Python-checkins] cpython (2.7): Brought excluded code into the scope of a try block in SysLogHandler.emit().

vinay.sajip python-checkins at python.org
Sat Nov 1 21:01:12 CET 2014


https://hg.python.org/cpython/rev/ea7b64406396
changeset:   93332:ea7b64406396
branch:      2.7
parent:      93326:3f13f1620d70
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Sat Nov 01 19:56:13 2014 +0000
summary:
  Brought excluded code into the scope of a try block in SysLogHandler.emit().

files:
  Lib/logging/handlers.py |  22 +++++++++++-----------
  Misc/NEWS               |   3 +++
  2 files changed, 14 insertions(+), 11 deletions(-)


diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -840,18 +840,18 @@
         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'
-        """
-        We need to convert record level to lowercase, maybe this will
-        change in the future.
-        """
-        prio = '<%d>' % self.encodePriority(self.facility,
-                                            self.mapPriority(record.levelname))
-        # Message is a string. Convert to bytes as required by RFC 5424
-        if type(msg) is unicode:
-            msg = msg.encode('utf-8')
-        msg = prio + msg
         try:
+            msg = self.format(record) + '\000'
+            """
+            We need to convert record level to lowercase, maybe this will
+            change in the future.
+            """
+            prio = '<%d>' % self.encodePriority(self.facility,
+                                                self.mapPriority(record.levelname))
+            # Message is a string. Convert to bytes as required by RFC 5424
+            if type(msg) is unicode:
+                msg = msg.encode('utf-8')
+            msg = prio + msg
             if self.unixsocket:
                 try:
                     self.socket.send(msg)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,9 @@
 Library
 -------
 
+- Issue #22776: Brought excluded code into the scope of a try block in
+  SysLogHandler.emit().
+ 
 - Issue #17381: Fixed ranges handling in case-insensitive regular expressions.
 
 - Issue #19329: Optimized compiling charsets in regular expressions.

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


More information about the Python-checkins mailing list