This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tempfile.TemporaryDirectory() should behave the same as a context manager as when used directly
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Pat Gunn
Priority: normal Keywords:

Created on 2019-09-26 16:29 by Pat Gunn, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg353327 - (view) Author: Pat Gunn (Pat Gunn) Date: 2019-09-26 16:29
Right now, when tempfile.TemporaryDirectory() is used as a context manager, the context variable is stringy, usable as a string containing the directory name it made. When used directly, it returns an object that does not coerce to a nice string, instead requiring the .name method to be called.

I propose adding a __str__() to the class that causes it to serialise nicely into a string containing just the directory name, so the (in my view surprising) differences in behaviour are minimised.
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82468
2019-09-26 16:29:50Pat Gunncreate