[New-bugs-announce] [issue38287] tempfile.TemporaryDirectory() should behave the same as a context manager as when used directly

Pat Gunn report at bugs.python.org
Thu Sep 26 12:29:50 EDT 2019


New submission from Pat Gunn <pgunn01 at gmail.com>:

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.

----------
components: Library (Lib)
messages: 353327
nosy: Pat Gunn
priority: normal
severity: normal
status: open
title: tempfile.TemporaryDirectory() should behave the same as a context manager as when used directly
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38287>
_______________________________________


More information about the New-bugs-announce mailing list