[issue31959] Directory at `TemporaryDirectory().name` does not exist

2017-11-06 Thread Adam Dangoor
Adam Dangoor added the comment: Thank you for clearing this up for me. -- ___ Python tracker ___

[issue31959] Directory at `TemporaryDirectory().name` does not exist

2017-11-06 Thread Martin Panter
Change by Martin Panter : -- nosy: +serhiy.storchaka resolution: wont fix -> not a bug stage: -> resolved ___ Python tracker ___

[issue31959] Directory at `TemporaryDirectory().name` does not exist

2017-11-06 Thread Martin Panter
Martin Panter added the comment: The documentation says “On . . . destruction of the temporary directory object the newly created temporary directory and all its contents are removed”. If you had enabled warnings, you may have seen a hint: $ python -Wdefault -c 'import

[issue31959] Directory at `TemporaryDirectory().name` does not exist

2017-11-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This is by design. The first TemporaryDirectory object is destroyed before the first print statement. For not be surprised use TemporaryDirectory with the "with" statement. with TemporaryDirectory() as td: name = td.name

[issue31959] Directory at `TemporaryDirectory().name` does not exist

2017-11-06 Thread Adam Dangoor
Adam Dangoor added the comment: > The unexpected behavior occurs on CPython 3.5.3 and CPython 3.6.X but not on > pypy. This suggests that it is something to do with garbage collection. Upon further thought, maybe this is by design, but I still was surprised.

[issue31959] Directory at `TemporaryDirectory().name` does not exist

2017-11-06 Thread Adam Dangoor
New submission from Adam Dangoor : Sample code: ``` import os from tempfile import TemporaryDirectory name = TemporaryDirectory().name print(os.path.exists(name)) # prints False td = TemporaryDirectory() name_2 = td.name print(os.path.exists(name_2)) # prints True ```