classification
Title: AbstractContextManager should support __method__ = None
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mariatta Nosy List: Jelle Zijlstra, Mariatta, gvanrossum, levkivskyi, ncoghlan, yselivanov
Priority: normal Keywords:

Created on 2017-05-04 03:37 by Jelle Zijlstra, last changed 2017-06-10 04:37 by Jelle Zijlstra. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1448 merged Jelle Zijlstra, 2017-05-04 03:42
PR 2054 merged Mariatta, 2017-06-10 01:10
Messages (7)
msg292955 - (view) Author: Jelle Zijlstra (Jelle Zijlstra) * (Python triager) Date: 2017-05-04 03:37
Like other ABCs, contextlib.AbstractContextManager should support the pattern where setting a method to None disables structural subtyping, which was introduced across the standard library in issue 25958. Ivan Levkivskyi suggested making AbstractContextManager support this pattern in CR comments in https://github.com/python/cpython/pull/1412/files#r114482765.

Should this change be applied to 3.6 as well as master? I'm leaning towards yes, because the resolution to issue 25958 (https://hg.python.org/cpython/rev/72b9f195569c) added a general statement in the documentation that "Setting a special method to ``None`` indicates that the corresponding operation is not available". Thus, the fact that contextlib.AbstractContextManager doesn't obey this rule is a bug.

I'll send a PR shortly.
msg295541 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2017-06-09 15:21
New changeset 57161aac5eb9bcb0b43e551a1937ff0a84c1ec52 by Guido van Rossum (Jelle Zijlstra) in branch 'master':
bpo-30266: support "= None" pattern in AbstractContextManager (#1448)
https://github.com/python/cpython/commit/57161aac5eb9bcb0b43e551a1937ff0a84c1ec52
msg295547 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2017-06-09 15:55
This should be backported to 3.6.
msg295603 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 03:36
New changeset 753422f6e32e13d96319b090788f0474f1e21fc4 by Mariatta in branch '3.6':
bpo-30266: support "= None" pattern in AbstractContextManager (GH-1448) (GH-2054)
https://github.com/python/cpython/commit/753422f6e32e13d96319b090788f0474f1e21fc4
msg295604 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 03:38
PR has been backported to 3.6.

Thanks :)
msg295607 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2017-06-10 04:12
Thanks Mariatta!
msg295608 - (view) Author: Jelle Zijlstra (Jelle Zijlstra) * (Python triager) Date: 2017-06-10 04:37
Thanks for doing the merge and backport!
History
Date User Action Args
2017-06-10 04:37:55Jelle Zijlstrasetmessages: + msg295608
2017-06-10 04:12:43gvanrossumsetmessages: + msg295607
2017-06-10 03:38:08Mariattasetstatus: open -> closed
resolution: fixed
messages: + msg295604

stage: backport needed -> resolved
2017-06-10 03:36:30Mariattasetmessages: + msg295603
2017-06-10 01:10:25Mariattasetpull_requests: + pull_request2114
2017-06-09 16:17:55Mariattasetassignee: Mariatta

nosy: + Mariatta
stage: backport needed
2017-06-09 15:55:37gvanrossumsetmessages: + msg295547
2017-06-09 15:21:50gvanrossumsetnosy: + gvanrossum
messages: + msg295541
2017-05-04 03:42:12Jelle Zijlstrasetpull_requests: + pull_request1546
2017-05-04 03:37:32Jelle Zijlstracreate