-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Open
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
In the tempfile module, TemporaryFile is defined as an alias for NamedTemporaryFile for non-posix systems:
https://github.com/python/cpython/blob/main/Lib/tempfile.py#L620-L623
That means that in, e.g. Linux, the args are:
def TemporaryFile(mode='w+b', buffering=-1, encoding=None,
newline=None, suffix=None, prefix=None,
dir=None, *, errors=None)while in, e.g. Windows, they are:
def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
newline=None, suffix=None, prefix=None,
dir=None, delete=True, *, errors=None,
delete_on_close=True)Static checkers such as VSCode pick up on this and let me write code like this:
with TemporaryFile(delete=False) as tmp:
...and it will run fine in Windows but not anywhere else.
I believe TemporaryFile should not just be a simple alias for non-posix systems; it can certainly wrap NamedTemporaryFile, but should have the exact same signature across platforms.
CPython versions tested on:
3.12
Operating systems tested on:
Linux, Windows
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error