Merge pull request #24068 from eduNEXT/defz/3521-resourcewarning-unclosed-file

Added 'with' statement to close file before returning
This commit is contained in:
Ned Batchelder
2020-05-29 16:43:54 -04:00
committed by GitHub

View File

@@ -17,7 +17,8 @@ LOG = logging.getLogger(__name__)
def load_json_from_file(filename):
return json.load(codecs.open(filename, encoding='utf-8'))
with codecs.open(filename, encoding='utf-8') as file:
return json.load(file)
class Command(BaseCommand):