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

typing.py has an incorrect definition of closed #83674

Closed
hauntsaninja opened this issue Jan 30, 2020 · 5 comments
Closed

typing.py has an incorrect definition of closed #83674

hauntsaninja opened this issue Jan 30, 2020 · 5 comments
Labels
3.8 only security fixes

Comments

@hauntsaninja
Copy link
Contributor

BPO 39493
Nosy @gvanrossum, @miss-islington, @hauntsaninja
PRs
  • bpo-39493: Fix definition of IO.closed in typing.py #18265
  • [3.7] bpo-39493: Fix definition of IO.closed in typing.py (GH-18265) #18273
  • [3.8] bpo-39493: Fix definition of IO.closed in typing.py (GH-18265) #18274
  • 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 2020-01-30.06:00:37.441>
    created_at = <Date 2020-01-30.00:37:07.981>
    labels = ['3.8']
    title = 'typing.py has an incorrect definition of closed'
    updated_at = <Date 2020-01-30.06:00:37.440>
    user = 'https://github.com/hauntsaninja'

    bugs.python.org fields:

    activity = <Date 2020-01-30.06:00:37.440>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-30.06:00:37.441>
    closer = 'gvanrossum'
    components = []
    creation = <Date 2020-01-30.00:37:07.981>
    creator = 'hauntsaninja'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39493
    keywords = ['patch']
    message_count = 5.0
    messages = ['360996', '361004', '361010', '361011', '361012']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'miss-islington', 'hauntsaninja']
    pr_nums = ['18265', '18273', '18274']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39493'
    versions = ['Python 3.8']

    @hauntsaninja
    Copy link
    Contributor Author

    Hello!

    typing.py has the following definition of closed:
    https://github.com/python/cpython/blob/master/Lib/typing.py#L1834

        @abstractmethod
        def closed(self) -> bool:
            pass
    

    This is inconsistent with the behaviour at runtime:

    In [17]: sys.version                                                                                                  
    Out[17]: '3.8.1 (default, Jan 23 2020, 23:36:06) \n[Clang 11.0.0 (clang-1100.0.33.17)]'
    
    In [18]: f = open("test", "w")                                                                                        
    
    In [19]: f.closed                                                                                                     
    Out[19]: False
    

    It seems like the right thing to do is add an @Property, as we do with e.g. mode and name. I'll submit a PR with this change.

    Note typeshed also types this as a property to indicate a read-only attribute.
    https://github.com/python/typeshed/blob/master/stdlib/3/typing.pyi#L459

    First time filing a bug on BPO, thanks a lot in advance!

    @hauntsaninja hauntsaninja added the 3.8 only security fixes label Jan 30, 2020
    @gvanrossum
    Copy link
    Member

    New changeset 2e6569b by Shantanu in branch 'master':
    bpo-39493: Fix definition of IO.closed in typing.py (bpo-18265)
    2e6569b

    @miss-islington
    Copy link
    Contributor

    New changeset 58076df by Miss Islington (bot) in branch '3.8':
    bpo-39493: Fix definition of IO.closed in typing.py (GH-18265)
    58076df

    @gvanrossum
    Copy link
    Member

    New changeset 194c7ae by Miss Islington (bot) in branch '3.7':
    [3.7] bpo-39493: Fix definition of IO.closed in typing.py (GH-18273)
    194c7ae

    @gvanrossum
    Copy link
    Member

    Thanks, Shantanu!

    @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 only security fixes
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants