Skip to content

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Mar 3, 2025

Pass delete_on_close=False to NamedTemporaryFile().

The behavior of
NamedTemporaryFile()
is slightly different on Windows when the file is accessed multiple times in
the same context manager. delete_on_close=False allows the file to exist
until the end of the context manager, which is the behavior we want in all
platforms.

Unfortunately this argument was only added in Python 3.12, so we add a switch
to support earlier versions. We may remove it in the future once 3.11 is EOL.

Please see PR #265 for
details (and thanks to @NingLi670 for opening the original PR).

@copybara-service copybara-service bot force-pushed the test_732946651 branch 3 times, most recently from 9efb6cd to 58dd015 Compare March 3, 2025 17:59
The behavior of
[`NamedTemporaryFile()`](https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile)
is slightly different on Windows when the file is accessed multiple times in
the same context manager. `delete_on_close=False` allows the file to exist
until the end of the context manager, which is the behavior we want in all
platforms.

Unfortunately this argument was only added in Python `3.12`, so we add a switch
to support earlier versions. We may remove it in the future once `3.11` is EOL.

Please see PR #265 for
details (and thanks to @NingLi670 for opening the original PR).

PiperOrigin-RevId: 732961399
@copybara-service copybara-service bot merged commit c16c209 into main Mar 3, 2025
@copybara-service copybara-service bot deleted the test_732946651 branch March 3, 2025 18:00
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

Successfully merging this pull request may close these issues.

2 participants