Merge "Drop logic for old python versions"

This commit is contained in:
Zuul 2024-09-17 23:59:22 +00:00 committed by Gerrit Code Review
commit 5bf57caed7
2 changed files with 3 additions and 11 deletions

View File

@ -75,11 +75,7 @@ def main():
# non-buffered behaviour. on python3, sys.stdin was
# opened with the system encoding and made the line into
# utf-8, so write the logfile out in utf-8 bytes.
if sys.version_info < (3,):
outfile.write(ts_line)
else:
outfile.write(
ts_line.encode('utf-8', errors='surrogateescape'))
outfile.write(ts_line.encode('utf-8', errors='surrogateescape'))
outfile.flush()

View File

@ -26,7 +26,6 @@ import json
import logging
import logging.config
import os
import sys
# A simple formatter to more or less copy oslo.log's ContextFormatter
@ -43,11 +42,8 @@ class DibFormatter(logging.Formatter):
else:
fmt = self.fmt
if sys.version_info < (3, 2):
self._fmt = fmt
else:
self._style = logging.PercentStyle(fmt)
self._fmt = self._style._fmt
self._style = logging.PercentStyle(fmt)
self._fmt = self._style._fmt
return logging.Formatter.format(self, record)