Skip to content

Commit 9a55819

Browse files
committed
v2: load returns None if nothing was parsed
1 parent f0fac06 commit 9a55819

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

javaobj/v2/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ def load(file_object: IO[bytes], *transformers: ObjectTransformer, **kwargs):
3434
parser = JavaStreamParser(file_object, all_transformers)
3535
contents = parser.run()
3636

37-
if len(contents) == 1:
37+
if len(contents) == 0:
38+
# Nothing was parsed, but no error
39+
return None
40+
elif len(contents) == 1:
3841
# Return the only object as is
3942
return contents[0]
40-
41-
# Returns all objects if they are more than one
42-
return contents
43+
else:
44+
# Returns all objects if they are more than one
45+
return contents
4346

4447

4548
def loads(data: bytes, *transformers: ObjectTransformer, **kwargs):

0 commit comments

Comments
 (0)