Skip to content

Commit

Permalink
fix: Read bytes to avoid ijson deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Aug 23, 2024
1 parent 2efebf8 commit 76b12c5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion flattentool/json_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def __init__(
else:
path = root_list_path.replace("/", ".") + ".item"

json_file = codecs.open(json_filename, encoding="utf-8")
json_file = codecs.open(json_filename, "rb")

self.root_json_list = ijson.items(json_file, path, map_type=OrderedDict)

Expand Down
4 changes: 0 additions & 4 deletions flattentool/tests/test_json_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from flattentool.json_input import (
BadlyFormedJSONError,
BadlyFormedJSONErrorUTF8,
JSONParser,
)
from flattentool.schema import SchemaParser
Expand All @@ -35,9 +34,6 @@ def test_jsonparser_bad_json_utf8():
name = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "fixtures", "bad-utf8.json"
)
# matches against the special error type
with pytest.raises(BadlyFormedJSONErrorUTF8):
JSONParser(json_filename=name)
# matches against our base error type
with pytest.raises(BadlyFormedJSONError):
JSONParser(json_filename=name)
Expand Down

0 comments on commit 76b12c5

Please sign in to comment.