[issue14515] tempfile.TemporaryDirectory documented as returning object but returns name

New submission from R. David Murray <rdmurray@bitdance.com>: 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. ---------- assignee: docs@python components: Documentation messages: 157635 nosy: docs@python, r.david.murray priority: normal severity: normal stage: needs patch status: open title: tempfile.TemporaryDirectory documented as returning object but returns name type: behavior versions: Python 3.2, Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

R. David Murray <rdmurray@bitdance.com> added the comment: 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. ---------- keywords: +patch nosy: +ncoghlan Added file: http://bugs.python.org/file25179/tempdir-doc.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

Nick Coghlan <ncoghlan@gmail.com> added the comment: Change looks fine to me - go ahead and commit it :) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

Serhiy Storchaka added the comment: I don't understand a phrase "and is assigned to the target of the as clause on entry to a context". Typo? ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

R. David Murray added the comment: 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? ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

Serhiy Storchaka added the comment: Aha, now it makes a sense to me. I don't know which variant will be clear. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

Changes by Ezio Melotti <ezio.melotti@gmail.com>: ---------- nosy: +ezio.melotti, terry.reedy stage: needs patch -> patch review versions: +Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

Yury Selivanov added the comment: bump? ---------- nosy: +yselivanov _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________

R. David Murray added the comment: 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'.) ---------- stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14515> _______________________________________
participants (6)
-
Ezio Melotti
-
Nick Coghlan
-
R. David Murray
-
Roundup Robot
-
Serhiy Storchaka
-
Yury Selivanov