From 58a44a8ea1e48ba8936485086794cb59795a2d03 Mon Sep 17 00:00:00 2001 From: Gwenael Lambrouin Date: Tue, 24 Aug 2021 11:42:26 +0200 Subject: Be explicit about text file encoding Python PEP 597 (https://www.python.org/dev/peps/pep-0597) recommends to use an explicit encoding for text files instead of the default locale encoding. Pylint 2.10 adds a new checker named unspecified-encoding for that. The present patch adds explicit utf-8 encoding to open() calls in nfvbench and fixes pylint unspecified-encoding warnings. Remark: this patch does not change nfvbench behaviour on systems where utf-8 is the locale encoding, which is generally the case on Linux systems. Change-Id: Ic4dfb37e1ea958452a0173f7630a68f0d95071ae Signed-off-by: Gwenael Lambrouin --- nfvbench/nfvbench.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nfvbench/nfvbench.py') diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py index 740dca2..891b2bb 100644 --- a/nfvbench/nfvbench.py +++ b/nfvbench/nfvbench.py @@ -721,7 +721,7 @@ def main(): sys.exit(0) if opts.summary: - with open(opts.summary) as json_data: + with open(opts.summary, encoding="utf-8") as json_data: result = json.load(json_data) if opts.user_label: result['config']['user_label'] = opts.user_label @@ -736,7 +736,7 @@ def main(): # dump the contents of the trex log file if opts.show_trex_log: try: - with open('/tmp/trex.log') as trex_log_file: + with open('/tmp/trex.log', encoding="utf-8") as trex_log_file: print(trex_log_file.read(), end="") except FileNotFoundError: print("No TRex log file found!") -- cgit 1.2.3-korg