We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 067cac2 commit 253a275Copy full SHA for 253a275
src/sagemaker/serializers.py
@@ -381,10 +381,9 @@ def serialize(self, data):
381
"""
382
if isinstance(data, str):
383
try:
384
- dataFile = open(data, "rb")
385
- dataFileInfo = dataFile.read()
386
- dataFile.close()
387
- return dataFileInfo
+ with open(data, "rb") as data_file:
+ data_file_info = data_file.read()
+ return data_file_info
388
except Exception as e:
389
raise ValueError(f"Could not open/read file: {data}. {e}")
390
if isinstance(data, bytes):
0 commit comments