From d3bd4e6c1ff781addf7a91dddd404e02b134a7c0 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Wed, 19 Jul 2023 08:26:36 -0700 Subject: [PATCH 1/3] utility_functions: reader: use stdout encoding the reader() function, used to parse the output of a subprocess would decode using a different standard as specified by locale.getdefaultlocale(), which was deprecated. This commit changes the decode format to be sys.stdout.encoding, which is more accurate than locale.getdefaultlocale() as it is the actual encoding of stdout, which is what the reader function is decoding --- edk2toollib/utility_functions.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/edk2toollib/utility_functions.py b/edk2toollib/utility_functions.py index 7a917674..a49d55d6 100644 --- a/edk2toollib/utility_functions.py +++ b/edk2toollib/utility_functions.py @@ -10,7 +10,6 @@ import datetime import importlib import inspect -import locale import logging import os import platform @@ -70,9 +69,8 @@ def reader(filepath, outstream, stream, logging_level=logging.INFO, encodingErro if (filepath): f = open(filepath, "w") - (_, encoding) = locale.getdefaultlocale() while True: - s = stream.readline().decode(encoding or 'utf-8', errors=encodingErrors) + s = stream.readline().decode(sys.stdout.encoding) if not s: break if (f is not None): From 164ba55600c45bc1f824ee4f4ee1fc9637bca855 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Wed, 19 Jul 2023 08:34:02 -0700 Subject: [PATCH 2/3] update --- edk2toollib/utility_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edk2toollib/utility_functions.py b/edk2toollib/utility_functions.py index a49d55d6..0f557041 100644 --- a/edk2toollib/utility_functions.py +++ b/edk2toollib/utility_functions.py @@ -70,7 +70,7 @@ def reader(filepath, outstream, stream, logging_level=logging.INFO, encodingErro f = open(filepath, "w") while True: - s = stream.readline().decode(sys.stdout.encoding) + s = stream.readline().decode(sys.stdout.encoding, errors=encodingErrors) if not s: break if (f is not None): From 65e70f7313091fa69e09e54499fe7e863bf47340 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Thu, 3 Aug 2023 10:37:32 -0700 Subject: [PATCH 3/3] update --- edk2toollib/utility_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edk2toollib/utility_functions.py b/edk2toollib/utility_functions.py index 0f557041..04c54fa4 100644 --- a/edk2toollib/utility_functions.py +++ b/edk2toollib/utility_functions.py @@ -70,7 +70,7 @@ def reader(filepath, outstream, stream, logging_level=logging.INFO, encodingErro f = open(filepath, "w") while True: - s = stream.readline().decode(sys.stdout.encoding, errors=encodingErrors) + s = stream.readline().decode(sys.stdout.encoding or 'utf-8', errors=encodingErrors) if not s: break if (f is not None):