-
Notifications
You must be signed in to change notification settings - Fork 6
Assure powrap is compatible with Windows #105
Conversation
delete = os.name == "posix" and sys.platform != "cygwin" | ||
|
||
with NamedTemporaryFile("w+", delete=delete, encoding="utf-8") as tmpfile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workaround for https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile:
Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows). If delete is true (the default), the file is deleted as soon as it is closed.
We simply don't delete the file after it is created, making it possible to write into it while it is still open. (For non-Posix systems)
if not delete: | ||
os.remove(tmpfile.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We manually delete the temp file after every iteration.
#106 should obviate this. |
Released a tag on egeakman/powrap:v1.0.1 for temporary use in python-docs-tr |
Ping @JulienPalard |
I'm lagging behind! oO |
Release v1.0.1 on PyPI. |
Hopefully closes #104
All tests are passing. I additionally tested it with different files and conditions.
Can you check if everything is okay @JulienPalard?