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
`--preserve-manifest` was doing the opposite of what it meant to do:
deleting the manifest file when `--preserve-manifest` was given and not
deleting it when it was not given.
But simply changing
```py
with tempfile.NamedTemporaryFile(suffix=".manifest", mode='w+', delete=args.preserve_manifest) as f:
```
```py
with tempfile.NamedTemporaryFile(suffix=".manifest", mode='w+', delete=not args.preserve_manifest) as f:
```
doesn't work, because of Windows' peculiar behavior.
It looks in Windows it is not allowed to re-open an already opened file
unless some conditions are met:
https://docs.python.org/3/library/tempfile.html
> Opening the temporary file again by its name while it is still open
works as follows:
> - On POSIX the file can always be opened again.
> - On Windows, make sure that at least one of the following conditions
are fulfilled:
> - `delete` is false
> - additional open shares delete access (e.g. by calling
[os.open()](https://docs.python.org/3/library/os.html#os.open) with the
flag `O_TEMPORARY`)
> - `delete` is true but `delete_on_close` is false. Note, that in this
case the additional opens that do not share delete access (e.g. created
via builtin
[open()](https://docs.python.org/3/library/functions.html#open)) must be
closed before exiting the context manager, else the
[os.unlink()](https://docs.python.org/3/library/os.html#os.unlink) call
on context manager exit will fail with a
[PermissionError](https://docs.python.org/3/library/exceptions.html#PermissionError).
And we are trying to reopen a temporary file within the `with` context.
The Windows CI didn't error out before this PR because the first
condition (`delete` is false) was accidentally satisfied due to this
bug. To fix this I think we can't help but use `try`-`finally`.
0 commit comments