]> granicus.if.org Git - python/commitdiff
Brought excluded code into the scope of a try block in SysLogHandler.emit().
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 1 Nov 2014 19:56:13 +0000 (19:56 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 1 Nov 2014 19:56:13 +0000 (19:56 +0000)
Lib/logging/handlers.py
Misc/NEWS

index 201d2b5a7d6985584a562c768b0aa9e2876ce1b3..a458529684f214ed7cc44baac5bd108609b9cada 100644 (file)
@@ -840,18 +840,18 @@ class SysLogHandler(logging.Handler):
         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)
index 5c038877128356ddbab8ae00de53c4cae1f345cf..1ef092c2abff18b4a637403af6ff79414db7e1f3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,9 @@ Core and Builtins
 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.