Repository navigation
logging.handlers.DatagramHandler sends bad data to socketserver.DatagramRequestHandler #81512
Description
Activity
pysyslog.py- A UDP server listens at 0.0.0.0:514 for syslog messages.
syslogmsg_gen.py- Send syslog message to local syslog server via 127.0.0.1:514
Error:
Exception has occurred: UnicodeDecodeError
'utf-8' codec can't decode byte 0xd7 in position 381: invalid continuation byte
File "C:\pysyslog.py", line 21, in handle
data = self.request[0].decode('utf-8')
File "C:\pysyslog.py", line 28, in <module>
server.serve_forever(poll_interval=0.5)- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.7 (EOL)end of lifeend of lifetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jun 18, 2019 I did some checks, I discovered the following:
logging.handlers.DatagramHandler() sends data in the following format:
- message length
- message itself which consists of
a. Creation time in ASCII format
b. Creation time in seconds, ms
c. Filename, line no
d. Message level
e. Message
f. Logger name
etc.
Item 1. is packed using struct.pack(">L")
Item 2. is packed using pickleThe message format is not mentioned in any of the standard Python document. Also it may not be compatible with third-party syslog message library or generator.
It is mentioned here:
although that doesn't go into the detail of the struct.pack format. I'll update the documentation to rectify this.
- addeddocsDocumentation in the Doc dirDocumentation in the Doc dirand removedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Jun 19, 2019
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: