You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering a TypeError when attempting to load a pickle file using lsf_runner.py. The code in lsf_runner.py opens the job-instance.pickle file in text mode ("r") and then calls pickle.load(). In Python 3, pickle.load() expects a binary stream, and opening the file in text mode results in a TypeError: a bytes-like object is required, not 'str'.
Steps to Reproduce:
Run lsf_runner.py with a job-instance.pickle file that has been generated in any manner (binary or ASCII protocol).
Observe that lsf_runner.py opens job-instance.pickle using open("job-instance.pickle", "r").
pickle.load() (or dill.load()) fails with TypeError: a bytes-like object is required, not 'str'.
Expected Behavior:
pickle.load() should successfully unpickle the object.
Actual Behavior:
The unpickling fails with a TypeError due to the file being opened in text mode.
Environment:
Python 3.x
dill / pickle module
lsf_runner.py script as provided by the repository.
Possible Solution:
Change the file opening mode in lsf_runner.py from "r" to "rb". For example:
with open("job-instance.pickle", "rb") as pickle_file_handle:
job = pickle.load(pickle_file_handle)
The text was updated successfully, but these errors were encountered:
I am encountering a TypeError when attempting to load a pickle file using lsf_runner.py. The code in lsf_runner.py opens the job-instance.pickle file in text mode ("r") and then calls pickle.load(). In Python 3, pickle.load() expects a binary stream, and opening the file in text mode results in a TypeError: a bytes-like object is required, not 'str'.
Steps to Reproduce:
Expected Behavior:
pickle.load() should successfully unpickle the object.
Actual Behavior:
The unpickling fails with a TypeError due to the file being opened in text mode.
Environment:
Possible Solution:
Change the file opening mode in lsf_runner.py from "r" to "rb". For example:
The text was updated successfully, but these errors were encountered: