bpo-39481: Generic alias support to ctypes.Array, LibraryLoader... by isidentical · Pull Request #19434 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 deletions Lib/ctypes/__init__.py
6 changes: 5 additions & 1 deletion Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
)
from collections.abc import *
from contextlib import AbstractContextManager, AbstractAsyncContextManager
from ctypes import Array, LibraryLoader
from os import DirEntry
from re import Pattern, Match
from types import GenericAlias, MappingProxyType
from urllib.parse import SplitResult, ParseResult
import typing

from typing import TypeVar
Expand All @@ -35,7 +37,9 @@ def test_subscriptable(self):
Mapping, MutableMapping, MappingView,
KeysView, ItemsView, ValuesView,
Sequence, MutableSequence,
MappingProxyType, DirEntry
MappingProxyType, DirEntry,
Array, LibraryLoader,
SplitResult, ParseResult

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing comma.

):
tname = t.__name__
with self.subTest(f"Testing {tname}"):
Expand Down
3 changes: 3 additions & 0 deletions Lib/urllib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import re
import sys
import types
import collections
import warnings

Expand Down Expand Up @@ -176,6 +177,8 @@ def port(self):
raise ValueError("Port out of range 0-65535")
return port

__class_getitem__ = classmethod(types.GenericAlias)


class _NetlocResultMixinStr(_NetlocResultMixinBase, _ResultMixinStr):
__slots__ = ()
Expand Down
8 changes: 7 additions & 1 deletion Modules/_ctypes/_ctypes.c