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: typing.py has an incorrect definition of closed
Type: Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, hauntsaninja, miss-islington
Priority: normal Keywords: patch

Created on 2020-01-30 00:37 by hauntsaninja, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18265 merged hauntsaninja, 2020-01-30 01:09
PR 18273 merged miss-islington, 2020-01-30 05:22
PR 18274 merged miss-islington, 2020-01-30 05:23
Messages (5)
msg360996 - (view) Author: Shantanu (hauntsaninja) * Date: 2020-01-30 00:37
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!
msg361004 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-01-30 02:52
New changeset 2e6569b6692298fcc9aae0df3eb3181adb2a5099 by Shantanu in branch 'master':
bpo-39493: Fix definition of IO.closed in typing.py (#18265)
https://github.com/python/cpython/commit/2e6569b6692298fcc9aae0df3eb3181adb2a5099
msg361010 - (view) Author: miss-islington (miss-islington) Date: 2020-01-30 05:42
New changeset 58076df0c59677111dc77b72852cb2a313a2ef91 by Miss Islington (bot) in branch '3.8':
bpo-39493: Fix definition of IO.closed in typing.py (GH-18265)
https://github.com/python/cpython/commit/58076df0c59677111dc77b72852cb2a313a2ef91
msg361011 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-01-30 06:00
New changeset 194c7aeb6f3d6c2b0015457d22b38253652f4f38 by Miss Islington (bot) in branch '3.7':
[3.7] bpo-39493: Fix definition of IO.closed in typing.py (GH-18273)
https://github.com/python/cpython/commit/194c7aeb6f3d6c2b0015457d22b38253652f4f38
msg361012 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-01-30 06:00
Thanks, Shantanu!
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83674
2020-01-30 06:00:37gvanrossumsetstatus: open -> closed
resolution: fixed
messages: + msg361012

stage: patch review -> resolved
2020-01-30 06:00:16gvanrossumsetmessages: + msg361011
2020-01-30 05:42:42miss-islingtonsetnosy: + miss-islington
messages: + msg361010
2020-01-30 05:23:05miss-islingtonsetpull_requests: + pull_request17649
2020-01-30 05:22:58miss-islingtonsetpull_requests: + pull_request17648
2020-01-30 02:52:40gvanrossumsetnosy: + gvanrossum
messages: + msg361004
2020-01-30 01:09:38hauntsaninjasetkeywords: + patch
stage: patch review
pull_requests: + pull_request17642
2020-01-30 00:37:07hauntsaninjacreate