Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-39481: Make weakref and WeakSet generic#19497

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gvanrossum merged 2 commits intopython:masterfromemmatyping:weakref
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionsLib/_weakrefset.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
# by abc.py to load everything else at startup.

from _weakref import ref
from types import GenericAlias

__all__ = ['WeakSet']

Expand DownExpand Up@@ -197,3 +198,5 @@ def isdisjoint(self, other):

def __repr__(self):
return repr(self.data)

__class_getitem__ = classmethod(GenericAlias)
2 changes: 2 additions & 0 deletionsLib/test/test_genericalias.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@
from urllib.parse import SplitResult, ParseResult
from unittest.case import _AssertRaisesContext
from queue import Queue, SimpleQueue
from weakref import WeakSet, ReferenceType, ref
import typing

from typing import TypeVar
Expand DownExpand Up@@ -67,6 +68,7 @@ def test_subscriptable(self):
Array, LibraryLoader,
SplitResult, ParseResult,
ValueProxy, ApplyResult,
WeakSet, ReferenceType, ref,
ShareableList, SimpleQueue,
Future, _WorkItem,
Morsel,
Expand Down
8 changes: 7 additions & 1 deletionObjects/weakrefobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -362,6 +362,12 @@ static PyMemberDef weakref_members[] = {
{NULL} /* Sentinel */
};

static PyMethodDef weakref_methods[] = {
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL} /* Sentinel */
};

PyTypeObject
_PyWeakref_RefType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
Expand DownExpand Up@@ -392,7 +398,7 @@ _PyWeakref_RefType = {
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
0, /*tp_methods*/
weakref_methods, /*tp_methods*/
weakref_members, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp