Add encoding-param to open(), in case the underlying OS has a different default (#3827)

This commit is contained in:
Bert Blommers 2021-04-01 16:51:10 +01:00 committed by GitHub
parent 1440709e4c
commit 39db57d151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)