Unverified Commit dbc12269 authored by Robert Baruch's avatar Robert Baruch Committed by GitHub
Browse files

Fix hf_argparser.parse_json_file to open file with utf-8 encoding, close file...

Fix hf_argparser.parse_json_file to open file with utf-8 encoding, close file when finished (#23194)

* Open json args in utf-8 encoding, close file when finished

* black formatted
parent 6f8a0284
...@@ -401,7 +401,7 @@ class HfArgumentParser(ArgumentParser): ...@@ -401,7 +401,7 @@ class HfArgumentParser(ArgumentParser):
- the dataclass instances in the same order as they were passed to the initializer. - the dataclass instances in the same order as they were passed to the initializer.
""" """
open_json_file = open(Path(json_file)) with open(Path(json_file), encoding="utf-8") as open_json_file:
data = json.loads(open_json_file.read()) data = json.loads(open_json_file.read())
outputs = self.parse_dict(data, allow_extra_keys=allow_extra_keys) outputs = self.parse_dict(data, allow_extra_keys=allow_extra_keys)
return tuple(outputs) return tuple(outputs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment