New submission from dwich <michal.konvali...@gmail.com>:
On Windows tempfile.TemporaryFile() accepts delete attribute. On Linux TemporaryFile() raises TypeError if delete attribute is used. In tempfile.py source is the code below which means that on Windows TemporaryFile behaves like NamedTemporaryFile. I suppose the code should not be changed but the behaviour should be mentioned in documentation. if _os.name != 'posix' or _os.sys.platform == 'cygwin': # On non-POSIX and Cygwin systems, assume that we cannot unlink a file # while it is open. TemporaryFile = NamedTemporaryFile Steps to reproduce: >>> import tempfile >>> tf = tempfile.TemporaryFile(delete=False) On Linux Python throws TypeError: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: TemporaryFile() got an unexpected keyword argument 'delete' On Windows Python does not throw TypeError because on Windows TemporaryFile is in fact NamedTemporaryFile which accepts delete attribute. Tested on all these versions: 3.7.0 64 bit, 3.6.5 32 bit, 3.5.4 32 bit, 3.4.4 32 bit, 2.7.15 32 bit Proposed text to tempfile.TemporaryFile documentation: On non POSIX or Cygwin platforms TemporaryFile behaves exacly like NamedTemporaryFile including the fact that TemporaryFile accepts delete attribute and does not raise TypeError: TemporaryFile() got an unexpected keyword argument 'delete'. ---------- assignee: docs@python components: Documentation messages: 323702 nosy: docs@python, dwich priority: normal severity: normal status: open title: On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34429> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com