From 39db57d151ff4e5b17186cbee246e645b58852b6 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Thu, 1 Apr 2021 16:51:10 +0100 Subject: [PATCH] Add encoding-param to open(), in case the underlying OS has a different default (#3827) --- moto/utilities/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/moto/utilities/utils.py b/moto/utilities/utils.py index 01d20e47..255d2919 100644 --- a/moto/utilities/utils.py +++ b/moto/utilities/utils.py @@ -1,6 +1,10 @@ import json import random import string +import six + +if six.PY2: + from io import open def random_string(length=None): @@ -18,5 +22,5 @@ def load_resource(filename): from pkg_resources import resource_filename load_resource(resource_filename(__name__, "resources/file.json")) """ - with open(filename, "r") as f: - return json.load(f, encoding="utf-8") + with open(filename, "r", encoding="utf-8") as f: + return json.load(f)