homepage

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: Use public classes for contextlib.suppress and redirect_stdout
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ncoghlan Nosy List: ethan.furman, larry, ncoghlan, python-dev, serhiy.storchaka
Priority: release blocker Keywords:

Created on 2013年10月21日 14:00 by ncoghlan, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (7)
msg200782 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年10月21日 14:00
I broke help() for instances of these context managers by trying to postpone exposing the class APIs until 3.5 (and didn't even record my full rationale, however flawed, in the associated comments).
The wrapper functions should be removed, making the classes the public implementation. I also plan to make the following changes (although I may end up moving them to separate issues):
- provide (and document) a public "target" attribute on redirect_stdout
- make redirect_stdout reentrant (and switch to ExitStack as the reusable-but-not-reentrant example)
- provide (and document) a public "exceptions" attribute on suppress
- return self from suppress.__enter__
msg201319 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年10月26日 06:46
I decided to defer adding any public attributes to these APIs - that greatly simplifies this patch, is more consistent with the draft wording in the PEP 8 update (issue 19331), and if the demand for improved introspection support is there, we can always add them for 3.5.
msg201323 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年10月26日 07:24
I checked the other classes in contextlib to ensure they also provided decent docstrings on instances. They were mostly OK, but @contextmanager itself doesn't provide useful docs when inspecting the result context manager instances directly. However, fixing that isn't trivial: see issue 19404 for details.
msg201325 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013年10月26日 08:08
New changeset 09153a9a3bb9 by Nick Coghlan in branch 'default':
Close #19330 by using public classes in contextlib
http://hg.python.org/cpython/rev/09153a9a3bb9 
msg201331 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013年10月26日 09:07
I suppose tests will fail when Python is compiled with --without-doc-strings options. Perhaps the test.support.requires_docstrings decorator should be used.
msg201338 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2013年10月26日 12:19
It also fails under -OO, so I changed that decorator to deal with that case as well.
msg201339 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013年10月26日 12:21
New changeset a9bbc2d0c1dc by Nick Coghlan in branch 'default':
Issue #19330: Handle the no-docstrings case in tests
http://hg.python.org/cpython/rev/a9bbc2d0c1dc 
History
Date User Action Args
2022年04月11日 14:57:52adminsetgithub: 63529
2013年10月26日 12:21:32python-devsetmessages: + msg201339
2013年10月26日 12:19:40ncoghlansetmessages: + msg201338
2013年10月26日 09:07:30serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg201331
2013年10月26日 08:08:28python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg201325

resolution: fixed
stage: needs patch -> resolved
2013年10月26日 07:24:38ncoghlansetmessages: + msg201323
2013年10月26日 06:46:34ncoghlansetmessages: + msg201319
2013年10月26日 06:44:17ncoghlanlinkissue19403 dependencies
2013年10月26日 06:32:43ncoghlanlinkissue19396 superseder
2013年10月21日 17:03:36ethan.furmansetnosy: + ethan.furman
2013年10月21日 14:00:52ncoghlancreate

AltStyle によって変換されたページ (->オリジナル) /