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/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nfvbench/utils.py') diff --git a/nfvbench/utils.py b/nfvbench/utils.py index 512422d..07a38cb 100644 --- a/nfvbench/utils.py +++ b/nfvbench/utils.py @@ -66,7 +66,7 @@ def save_json_result(result, json_file, std_json_path, service_chain, service_ch if filepaths: for file_path in filepaths: LOG.info('Saving results in json file: %s...', file_path) - with open(file_path, 'w') as jfp: + with open(file_path, 'w', encoding="utf-8") as jfp: json.dump(result, jfp, indent=4, -- cgit 1.2.3-korg