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: ContextVar[str] should return ContextVar class, not None
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Amir, asvetlov, miss-islington
Priority: normal Keywords: easy (C), patch

Created on 2019-12-05 13:04 by asvetlov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17497 merged Amir, 2019-12-07 13:10
PR 17505 closed miss-islington, 2019-12-08 11:36
PR 17506 merged miss-islington, 2019-12-08 11:36
PR 17507 merged miss-islington, 2019-12-08 12:25
Messages (8)
msg357850 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-12-05 13:04
The issue is minor, I suspect nobody wants to derive from ContextVar class.

The generic implementation for __class_getitem__ is returning unmodified self argument. Yuri, is there a reason to behave differently in the case of ContextVar?

If no, we can mark the issue as easy(C) and wait for a volunteer, the fix seems trivial.
msg357877 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-12-05 18:18
> The issue is minor, I suspect nobody wants to derive from ContextVar class.

I don't think that's allowed, actually.

> The generic implementation for __class_getitem__ is returning unmodified self argument. Yuri, is there a reason to behave differently in the case of ContextVar?

No, just an oversight, probably.
msg357887 - (view) Author: Florian Dahlitz (DahlitzFlorian) * Date: 2019-12-05 20:02
I'd be happy to work on this!
msg357963 - (view) Author: Amir Mohamadi (Amir) * Date: 2019-12-07 09:07
@asvetlov I have a question! Should "contextvar_cls_getitem" function be changed? And can you please help me figure out how to change it?
msg357964 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-12-07 10:28
I think it should look like the corresponding function from multidict: https://github.com/aio-libs/multidict/blob/master/multidict/_multidict.c#L803-L808

Please note, the method definition also should be updated, see https://github.com/aio-libs/multidict/blob/master/multidict/_multidict.c#L923-L928 for inspiration.
msg357997 - (view) Author: miss-islington (miss-islington) Date: 2019-12-08 11:36
New changeset 28c91631c24e53713ad0e8a2bbae716373f5e53d by Miss Islington (bot) (AMIR) in branch 'master':
bpo-38979: fix ContextVar "__class_getitem__" method (GH-17497)
https://github.com/python/cpython/commit/28c91631c24e53713ad0e8a2bbae716373f5e53d
msg357998 - (view) Author: miss-islington (miss-islington) Date: 2019-12-08 11:53
New changeset 9baa870c27b54c26f9dd292c26936b70bdb64a06 by Miss Islington (bot) in branch '3.7':
bpo-38979: fix ContextVar "__class_getitem__" method (GH-17497)
https://github.com/python/cpython/commit/9baa870c27b54c26f9dd292c26936b70bdb64a06
msg358001 - (view) Author: miss-islington (miss-islington) Date: 2019-12-08 12:49
New changeset 960fca1a5887a277fd6031cf4c4b6fb31b08ebf5 by Miss Islington (bot) in branch '3.8':
bpo-38979: fix ContextVar "__class_getitem__" method (GH-17497)
https://github.com/python/cpython/commit/960fca1a5887a277fd6031cf4c4b6fb31b08ebf5
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83160
2019-12-08 12:49:21asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-12-08 12:49:11miss-islingtonsetmessages: + msg358001
2019-12-08 12:25:10miss-islingtonsetpull_requests: + pull_request16984
2019-12-08 11:53:11miss-islingtonsetmessages: + msg357998
2019-12-08 11:36:40miss-islingtonsetpull_requests: + pull_request16983
2019-12-08 11:36:33miss-islingtonsetpull_requests: + pull_request16982
2019-12-08 11:36:06miss-islingtonsetnosy: + miss-islington
messages: + msg357997
2019-12-07 13:10:38Amirsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16975
2019-12-07 10:28:55asvetlovsetmessages: + msg357964
2019-12-07 09:07:51Amirsetnosy: + Amir, - gvanrossum, yselivanov, levkivskyi, DahlitzFlorian
messages: + msg357963
2019-12-05 20:02:04DahlitzFloriansetnosy: + DahlitzFlorian
messages: + msg357887
2019-12-05 18:33:32levkivskyisetkeywords: + easy (C)
2019-12-05 18:19:20serhiy.storchakasetnosy: + gvanrossum, levkivskyi
2019-12-05 18:18:11yselivanovsetmessages: + msg357877
2019-12-05 13:04:29asvetlovsettype: behavior
2019-12-05 13:04:18asvetlovcreate