classification
Title: repr() of buffered and text streams silences too many exceptions
Type: behavior Stage: resolved
Components: IO, Library (Lib) Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, miss-islington, serhiy.storchaka, stutzbach
Priority: normal Keywords: patch

Created on 2019-08-27 07:49 by serhiy.storchaka, last changed 2019-08-29 08:14 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15543 merged serhiy.storchaka, 2019-08-27 07:56
PR 15580 merged miss-islington, 2019-08-29 06:25
Messages (3)
msg350614 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-27 07:49
__repr__() implementations of buffered and text streams try to include the value of "name" and "mode" attributes in the result. But they silence too wide range of exceptions (all subclasses of Exception) when try to get these values. This includes such exceptions as MemoryError or RecursionError which can be occurred in virtually any code.

The proposed PR narrows the range of silenced exceptions to the necessary minimum: expected AttributeError and ValueError. The latter is raised if the underlying stream was detached.
msg350729 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-08-29 06:25
New changeset b235a1b47394eedc5f8ea4cf214f56c4c6932e59 by Serhiy Storchaka in branch 'master':
bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)
https://github.com/python/cpython/commit/b235a1b47394eedc5f8ea4cf214f56c4c6932e59
msg350752 - (view) Author: miss-islington (miss-islington) Date: 2019-08-29 08:13
New changeset 102130a63c93fde7bcabbbf4fae1ebce38888981 by Miss Islington (bot) in branch '3.8':
bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)
https://github.com/python/cpython/commit/102130a63c93fde7bcabbbf4fae1ebce38888981
History
Date User Action Args
2019-08-29 08:14:01serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 3.7
2019-08-29 08:13:34miss-islingtonsetnosy: + miss-islington
messages: + msg350752
2019-08-29 06:25:34miss-islingtonsetpull_requests: + pull_request15256
2019-08-29 06:25:27serhiy.storchakasetmessages: + msg350729
2019-08-27 07:56:54serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request15220
2019-08-27 07:50:04serhiy.storchakasetnosy: + benjamin.peterson, stutzbach
2019-08-27 07:49:40serhiy.storchakacreate