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.
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.
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?
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
2022-04-11 14:57:28
admin
set
github: 58720
2014-02-05 19:58:09
r.david.murray
set
status: open -> closedmessages: + stage: patch review -> resolved