Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File gets truncated upon unpickling #657

Open
JanPokorny opened this issue May 13, 2024 · 0 comments
Open

File gets truncated upon unpickling #657

JanPokorny opened this issue May 13, 2024 · 0 comments

Comments

@JanPokorny
Copy link

It seems that whenever a file is open for writing in the session, the (already closed) file object f gets unpickled in such a way that re-opens the file in writing mode, effectively truncating the file to zero length.

Is this expected behavior?

❯ python -c "
  with open('file.txt', 'w') as f:
    f.write('hello world')
  import dill
  dill.dump_module('session.pkl')
  "

❯ cat file.txt
hello world⏎                                                                                                                                                                                                                                                                                                                                                                                                   

❯ python -c "
  import dill
  dill.load_module('session.pkl')
  "

❯ cat file.txt

❯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant