From c33a0cc61ea763bde926b22492785f3b2b66685c Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Sat, 1 Nov 2014 19:58:47 +0000 Subject: Brought excluded code into the scope of a try block in SysLogHandler.emit(). --- Lib/logging/handlers.py | 28 ++++++++++++++-------------- Misc/NEWS | 3 +++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index b371824..43cbb55 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -879,21 +879,21 @@ 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) - if self.ident: - msg = self.ident + msg - if self.append_nul: - msg += '\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)) - prio = prio.encode('utf-8') - # Message is a string. Convert to bytes as required by RFC 5424 - msg = msg.encode('utf-8') - msg = prio + msg try: + msg = self.format(record) + if self.ident: + msg = self.ident + msg + if self.append_nul: + msg += '\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)) + prio = prio.encode('utf-8') + # Message is a string. Convert to bytes as required by RFC 5424 + msg = msg.encode('utf-8') + msg = prio + msg if self.unixsocket: try: self.socket.send(msg) diff --git a/Misc/NEWS b/Misc/NEWS index 9f9155d..97bb398 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -33,6 +33,9 @@ Core and Builtins Library ------- +- Issue #22776: Brought excluded code into the scope of a try block in + SysLogHandler.emit(). + - Issue #22665: Add missing get_terminal_size and SameFileError to shutil.__all__. -- cgit v0.12