]> git.pld-linux.org Git - packages/python3-numpy.git/blame - bpo-45167.patch
- package numpy.distutils.checks
[packages/python3-numpy.git] / bpo-45167.patch
CommitLineData
982d6a3c
JR
1From 8871c7285fc097fd1bf713aa184cba7e2804f625 Mon Sep 17 00:00:00 2001
2From: Bas van Beek <b.f.van.beek@vu.nl>
3Date: Wed, 10 Nov 2021 15:36:00 +0100
4Subject: [PATCH] MAINT: Do not forward `__(deep)copy__` calls of
5 `_GenericAlias` to the wrapped type
6
7Adapt to the python 3.9.8 changes made in bpo-45167.
8---
9 numpy/typing/_generic_alias.py | 2 ++
10 numpy/typing/tests/test_generic_alias.py | 16 ++++++++++++++++
11 2 files changed, 18 insertions(+)
12
13diff --git a/numpy/typing/_generic_alias.py b/numpy/typing/_generic_alias.py
14index 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:
18 "__mro_entries__",
19 "__reduce__",
20 "__reduce_ex__",
21+ "__copy__",
22+ "__deepcopy__",
23 })
24
25 def __getattribute__(self, name: str) -> Any:
26diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py
27index 3021d985934..39343420bdc 100644
28--- a/numpy/typing/tests/test_generic_alias.py
29+++ b/numpy/typing/tests/test_generic_alias.py
30@@ -1,6 +1,7 @@
31 from __future__ import annotations
32
33 import sys
34+import copy
35 import types
36 import pickle
37 import weakref
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
41
42+ @pytest.mark.parametrize("name,func", [
43+ ("__copy__", lambda n: n == copy.copy(n)),
44+ ("__deepcopy__", lambda n: n == copy.deepcopy(n)),
45+ ])
46+ def test_copy(self, name: str, func: FuncType) -> None:
47+ value = func(NDArray)
48+
49+ # xref bpo-45167
50+ GE_398 = (
51+ sys.version_info[:2] == (3, 9) and sys.version_info >= (3, 9, 8)
52+ )
53+ if GE_398 or sys.version_info >= (3, 10, 1):
54+ value_ref = func(NDArray_ref)
55+ assert value == value_ref
56+
57 def test_weakref(self) -> None:
58 """Test ``__weakref__``."""
59 value = weakref.ref(NDArray)()
This page took 0.033555 seconds and 4 git commands to generate.