Skip to content

Commit

Permalink
fix: make unicode work for python2/3
Browse files Browse the repository at this point in the history
  • Loading branch information
mdujava committed Dec 29, 2023
1 parent 0eb25e4 commit 13d452a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Common/bkr/common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import fcntl
import errno
from six.moves import queue
from builtins import str

log = getLogger(__name__)

Expand Down Expand Up @@ -100,7 +101,7 @@ def run(self):
self.finished.clear()


class SensitiveUnicode(unicode):
class SensitiveUnicode(str):
def __repr__(self):
return '<repr blocked>'

Expand Down
3 changes: 2 additions & 1 deletion Common/bkr/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import syslog
import logging
from builtins import str


def log_to_stream(stream, level=logging.WARNING):
Expand Down Expand Up @@ -46,7 +47,7 @@ class SysLogHandler(logging.Handler):
def emit(self, record):
priority = self._level_to_priority.get(record.levelno, syslog.LOG_WARNING)
msg = self.format(record)
if isinstance(msg, unicode):
if isinstance(msg, str):
msg = msg.encode('utf8')
msg = msg.replace('\x00', r'\x00')
for i, line in enumerate(msg.splitlines()):
Expand Down

0 comments on commit 13d452a

Please sign in to comment.