classification
Title: tempfile.TemporaryDirectory documented as returning object but returns name
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ezio.melotti, ncoghlan, python-dev, r.david.murray, serhiy.storchaka, terry.reedy, yselivanov
Priority: normal Keywords: patch

Created on 2012-04-06 02:07 by r.david.murray, last changed 2014-02-05 19:58 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
tempdir-doc.patch r.david.murray, 2012-04-11 17:48 review
Messages (9)
msg157635 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-04-06 02:07
The title pretty much says it all.  I believe the behavior is correct (more useful than returning an object that is only useful for obtaining the name) even though it is unusual for context managers.  In any case there is plenty of code using the existing behavior, so I think this is a doc bug.
msg158063 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-04-11 17:48
I misread the docs.  They aren't wrong, but it is still the case that they don't mention that the directory name is what you get on entry to the context, which is what led to my confusion.  

Here's a patch.
msg158100 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-04-12 02:09
Change looks fine to me - go ahead and commit it :)
msg182117 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-02-14 19:16
I don't understand a phrase "and is assigned to the target of the as clause on entry to a context". Typo?
msg182121 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-02-14 21:18
The patch is missing the markup for the 'as' keyword (it should read :keyword:`as`).  If that were added, would the sentence make sense to you?  Would it be clearer to say that the directory name is returned by the __enter__ method?
msg182122 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-02-14 21:29
Aha, now it makes a sense to me.

I don't know which variant will be clear.
msg209840 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-01-31 22:26
bump?
msg210344 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-02-05 19:56
New changeset b5fe07d39e16 by R David Murray in branch '3.3':
#14515: clarify that TemporaryDirectory's __enter__ returns the name.
http://hg.python.org/cpython/rev/b5fe07d39e16

New changeset 7b7e17723787 by R David Murray in branch 'default':
#14515: clarify that TemporaryDirectory's __enter__ returns the name.
http://hg.python.org/cpython/rev/7b7e17723787
msg210345 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-02-05 19:58
Just ran into this again :).  Committed a patch with wording clarified based on Serhiy's feedback (I say 'target of the as clause of the with statement'.)
History
Date User Action Args
2014-02-05 19:58:09r.david.murraysetstatus: open -> closed

messages: + msg210345
stage: patch review -> resolved
2014-02-05 19:56:52python-devsetnosy: + python-dev
messages: + msg210344
2014-01-31 22:26:19yselivanovsetnosy: + yselivanov
messages: + msg209840
2013-03-14 08:17:45ezio.melottisetnosy: + terry.reedy, ezio.melotti
stage: needs patch -> patch review

versions: + Python 3.4
2013-02-14 21:29:32serhiy.storchakasetmessages: + msg182122
2013-02-14 21:18:05r.david.murraysetmessages: + msg182121
2013-02-14 19:16:10serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg182117
2012-04-12 02:09:55ncoghlansetmessages: + msg158100
2012-04-11 17:48:06r.david.murraysetfiles: + tempdir-doc.patch

nosy: + ncoghlan
messages: + msg158063

keywords: + patch
2012-04-06 02:07:47r.david.murraycreate