Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c33a0cc

Browse files
committed
Brought excluded code into the scope of a try block in SysLogHandler.emit().
1 parent 8083cd6 commit c33a0cc

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

Lib/logging/handlers.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -879,21 +879,21 @@ def emit(self, record):
879879
The record is formatted, and then sent to the syslog server. If
880880
exception information is present, it is NOT sent to the server.
881881
"""
882-
msg = self.format(record)
883-
if self.ident:
884-
msg = self.ident + msg
885-
if self.append_nul:
886-
msg += '\000'
887-
888-
# We need to convert record level to lowercase, maybe this will
889-
# change in the future.
890-
prio = '<%d>' % self.encodePriority(self.facility,
891-
self.mapPriority(record.levelname))
892-
prio = prio.encode('utf-8')
893-
# Message is a string. Convert to bytes as required by RFC 5424
894-
msg = msg.encode('utf-8')
895-
msg = prio + msg
896882
try:
883+
msg = self.format(record)
884+
if self.ident:
885+
msg = self.ident + msg
886+
if self.append_nul:
887+
msg += '\000'
888+
889+
# We need to convert record level to lowercase, maybe this will
890+
# change in the future.
891+
prio = '<%d>' % self.encodePriority(self.facility,
892+
self.mapPriority(record.levelname))
893+
prio = prio.encode('utf-8')
894+
# Message is a string. Convert to bytes as required by RFC 5424
895+
msg = msg.encode('utf-8')
896+
msg = prio + msg
897897
if self.unixsocket:
898898
try:
899899
self.socket.send(msg)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Core and Builtins
3333
Library
3434
-------
3535

36+
- Issue #22776: Brought excluded code into the scope of a try block in
37+
SysLogHandler.emit().
38+
3639
- Issue #22665: Add missing get_terminal_size and SameFileError to
3740
shutil.__all__.
3841

0 commit comments

Comments
 (0)