From 0cb7573e53aaf772954a615f922e508636d5585d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 29 Dec 2020 17:00:19 +0100 Subject: [PATCH] usage of unicode is done through builtins attribute --- pype/lib/log.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pype/lib/log.py b/pype/lib/log.py index 80f4adbf31..55c6da0be6 100644 --- a/pype/lib/log.py +++ b/pype/lib/log.py @@ -40,11 +40,6 @@ except ImportError: else: _mongo_logging = True -try: - unicode - _unicode = True -except NameError: - _unicode = False PYPE_DEBUG = int(os.getenv("PYPE_DEBUG", "0")) @@ -113,6 +108,8 @@ def _bootstrap_mongo_log(components=None): LOG_COLLECTION_NAME, capped=True, max=5000, size=1073741824 ) return logdb +# Check for `unicode` in builtins +USE_UNICODE = hasattr(__builtins__, "unicode") class PypeStreamHandler(logging.StreamHandler): @@ -147,7 +144,8 @@ class PypeStreamHandler(logging.StreamHandler): msg = Terminal.log(msg) stream = self.stream fs = "%s\n" - if not _unicode: # if no unicode support... + # if no unicode support... + if not USE_UNICODE: stream.write(fs % msg) else: try: