From efb30e6456ff304ab08c6ef5eadb81ff2d05c76e Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Tue, 7 Apr 2020 23:24:59 +0300 Subject: [PATCH] bpo-39481: Generic alias to os.DirEntry --- Lib/test/test_genericalias.py | 3 ++- Modules/posixmodule.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py index 9d8dbfe04205fd..9c5b23e5e5b0fc 100644 --- a/Lib/test/test_genericalias.py +++ b/Lib/test/test_genericalias.py @@ -7,6 +7,7 @@ ) from collections.abc import * from contextlib import AbstractContextManager, AbstractAsyncContextManager +from os import DirEntry from re import Pattern, Match from types import GenericAlias, MappingProxyType import typing @@ -34,7 +35,7 @@ def test_subscriptable(self): Mapping, MutableMapping, MappingView, KeysView, ItemsView, ValuesView, Sequence, MutableSequence, - MappingProxyType, + MappingProxyType, DirEntry ): tname = t.__name__ with self.subTest(f"Testing {tname}"): diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 345798dc8c10de..47dfc3348822f1 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12975,6 +12975,8 @@ static PyMethodDef DirEntry_methods[] = { OS_DIRENTRY_STAT_METHODDEF OS_DIRENTRY_INODE_METHODDEF OS_DIRENTRY___FSPATH___METHODDEF + {"__class_getitem__", (PyCFunction)Py_GenericAlias, + METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, {NULL} };