Skip to content

Commit e35add5

Browse files
committed
Corrected methods signatures for Python 2 compatibility
1 parent 50db742 commit e35add5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

javaobj.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def read_to_str(data):
146146
# ------------------------------------------------------------------------------
147147

148148

149-
def load(file_object, *transformers, ignore_remaining_data=False):
149+
def load(file_object, *transformers, **kwargs):
150150
"""
151151
Deserializes Java primitive data and objects serialized using
152152
ObjectOutputStream from a file-like object.
@@ -157,6 +157,9 @@ def load(file_object, *transformers, ignore_remaining_data=False):
157157
trailing bytes are remaining
158158
:return: The deserialized object
159159
"""
160+
# Read keyword argument
161+
ignore_remaining_data = kwargs.get('ignore_remaining_data', False)
162+
160163
marshaller = JavaObjectUnmarshaller(file_object)
161164

162165
# Add custom transformers first
@@ -168,7 +171,7 @@ def load(file_object, *transformers, ignore_remaining_data=False):
168171
return marshaller.readObject(ignore_remaining_data=ignore_remaining_data)
169172

170173

171-
def loads(string, *transformers, ignore_remaining_data=False):
174+
def loads(string, *transformers, **kwargs):
172175
"""
173176
Deserializes Java objects and primitive data serialized using
174177
ObjectOutputStream from a string.
@@ -179,6 +182,9 @@ def loads(string, *transformers, ignore_remaining_data=False):
179182
trailing bytes are remaining
180183
:return: The deserialized object
181184
"""
185+
# Read keyword argument
186+
ignore_remaining_data = kwargs.get('ignore_remaining_data', False)
187+
182188
# Reuse the load method (avoid code duplication)
183189
return load(BytesIO(string), *transformers,
184190
ignore_remaining_data=ignore_remaining_data)

0 commit comments

Comments
 (0)