1 From 8871c7285fc097fd1bf713aa184cba7e2804f625 Mon Sep 17 00:00:00 2001
2 From: Bas van Beek <b.f.van.beek@vu.nl>
3 Date: Wed, 10 Nov 2021 15:36:00 +0100
4 Subject: [PATCH] MAINT: Do not forward `__(deep)copy__` calls of
5 `_GenericAlias` to the wrapped type
7 Adapt to the python 3.9.8 changes made in bpo-45167.
9 numpy/typing/_generic_alias.py | 2 ++
10 numpy/typing/tests/test_generic_alias.py | 16 ++++++++++++++++
11 2 files changed, 18 insertions(+)
13 diff --git a/numpy/typing/_generic_alias.py b/numpy/typing/_generic_alias.py
14 index 932f12dd05d..1eb2c8c05f0 100644
15 --- a/numpy/typing/_generic_alias.py
16 +++ b/numpy/typing/_generic_alias.py
17 @@ -185,6 +185,8 @@ def __eq__(self, value: object) -> bool:
25 def __getattribute__(self, name: str) -> Any:
26 diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py
27 index 3021d985934..39343420bdc 100644
28 --- a/numpy/typing/tests/test_generic_alias.py
29 +++ b/numpy/typing/tests/test_generic_alias.py
31 from __future__ import annotations
38 @@ -80,6 +81,21 @@ def test_pass(self, name: str, func: FuncType) -> None:
39 value_ref = func(NDArray_ref)
40 assert value == value_ref
42 + @pytest.mark.parametrize("name,func", [
43 + ("__copy__", lambda n: n == copy.copy(n)),
44 + ("__deepcopy__", lambda n: n == copy.deepcopy(n)),
46 + def test_copy(self, name: str, func: FuncType) -> None:
47 + value = func(NDArray)
51 + sys.version_info[:2] == (3, 9) and sys.version_info >= (3, 9, 8)
53 + if GE_398 or sys.version_info >= (3, 10, 1):
54 + value_ref = func(NDArray_ref)
55 + assert value == value_ref
57 def test_weakref(self) -> None:
58 """Test ``__weakref__``."""
59 value = weakref.ref(NDArray)()