Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repr() of buffered and text streams silences too many exceptions #82141

Closed
serhiy-storchaka opened this issue Aug 27, 2019 · 3 comments
Closed
Labels
3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir topic-IO type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 37960
Nosy @benjaminp, @serhiy-storchaka, @miss-islington
PRs
  • bpo-37960: Silence only necessary errors in repr() of buffered and text streams. #15543
  • [3.8] bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543) #15580
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-08-29.08:14:01.458>
    created_at = <Date 2019-08-27.07:49:40.349>
    labels = ['3.8', 'type-bug', 'library', '3.9', 'expert-IO']
    title = 'repr() of buffered and text streams silences too many exceptions'
    updated_at = <Date 2019-08-29.08:14:01.457>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-08-29.08:14:01.457>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-08-29.08:14:01.458>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)', 'IO']
    creation = <Date 2019-08-27.07:49:40.349>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37960
    keywords = ['patch']
    message_count = 3.0
    messages = ['350614', '350729', '350752']
    nosy_count = 4.0
    nosy_names = ['benjamin.peterson', 'stutzbach', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['15543', '15580']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37960'
    versions = ['Python 3.8', 'Python 3.9']

    @serhiy-storchaka
    Copy link
    Member Author

    __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.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir topic-IO type-bug An unexpected behavior, bug, or error labels Aug 27, 2019
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset b235a1b by Serhiy Storchaka in branch 'master':
    bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)
    b235a1b

    @miss-islington
    Copy link
    Contributor

    New changeset 102130a by Miss Islington (bot) in branch '3.8':
    bpo-37960: Silence only necessary errors in repr() of buffered and text streams. (GH-15543)
    102130a

    @serhiy-storchaka serhiy-storchaka removed the 3.7 (EOL) end of life label Aug 29, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir topic-IO type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants