cpython (merge 3.4 -> default): Closes #22776: Merged fix from 3.4.
![](https://secure.gravatar.com/avatar/8ac615df352a970211b0e3d94a307c6d.jpg?s=120&d=mm&r=g)
https://hg.python.org/cpython/rev/54549f9b2ecc changeset: 93334:54549f9b2ecc parent: 93331:149490bbd260 parent: 93333:f6a906541476 user: Vinay Sajip <vinay_sajip@yahoo.co.uk> date: Sat Nov 01 20:00:56 2014 +0000 summary: Closes #22776: Merged fix from 3.4. files: 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 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -879,21 +879,21 @@ 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' + 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 - try: + # 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 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -180,6 +180,9 @@ 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__. -- Repository URL: https://hg.python.org/cpython
participants (1)
-
vinay.sajip