Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/numpy/, dev-python/numpy/files/
Date: Sun, 15 Jul 2018 22:22:08
Message-Id: 1531693321.557f548a624556a208aef66a58b7b3cd3760558b.mgorny@gentoo
1 commit: 557f548a624556a208aef66a58b7b3cd3760558b
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jul 15 21:38:56 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Jul 15 22:22:01 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=557f548a
7
8 dev-python/numpy: Backport a fix for py3.7 test failures
9
10 dev-python/numpy/files/numpy-1.14.5-py37.patch | 135 +++++++++++++++++++++++++
11 dev-python/numpy/numpy-1.14.5.ebuild | 2 +
12 2 files changed, 137 insertions(+)
13
14 diff --git a/dev-python/numpy/files/numpy-1.14.5-py37.patch b/dev-python/numpy/files/numpy-1.14.5-py37.patch
15 new file mode 100644
16 index 00000000000..c53b3acf696
17 --- /dev/null
18 +++ b/dev-python/numpy/files/numpy-1.14.5-py37.patch
19 @@ -0,0 +1,135 @@
20 +From dce7f20e95e6bd3fc07517c0b2daf3942a34ddf7 Mon Sep 17 00:00:00 2001
21 +From: Charles Harris <charlesr.harris@×××××.com>
22 +Date: Wed, 14 Mar 2018 12:52:26 -0600
23 +Subject: [PATCH] MAINT: Fix test_utils.py for Python 3.7.
24 +
25 +The contents of the module warnings registries was made more module
26 +specific in Python 3.7 and consequently the tests of the context
27 +managers clear_and_catch_warnings and suppress_warnings need updating.
28 +---
29 + numpy/testing/tests/test_utils.py | 43 +++++++++++++++++++++----------
30 + 1 file changed, 29 insertions(+), 14 deletions(-)
31 +
32 +diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
33 +index a97b627f9..33b3555b0 100644
34 +--- a/numpy/testing/tests/test_utils.py
35 ++++ b/numpy/testing/tests/test_utils.py
36 +@@ -1114,18 +1114,28 @@ class TestStringEqual(unittest.TestCase):
37 + lambda: assert_string_equal("foo", "hello"))
38 +
39 +
40 +-def assert_warn_len_equal(mod, n_in_context, py3_n_in_context=None):
41 ++def assert_warn_len_equal(mod, n_in_context, py34=None, py37=None):
42 + mod_warns = mod.__warningregistry__
43 ++ num_warns = len(mod_warns)
44 + # Python 3.4 appears to clear any pre-existing warnings of the same type,
45 + # when raising warnings inside a catch_warnings block. So, there is a
46 + # warning generated by the tests within the context manager, but no
47 + # previous warnings.
48 + if 'version' in mod_warns:
49 +- if py3_n_in_context is None:
50 +- py3_n_in_context = n_in_context
51 +- assert_equal(len(mod_warns) - 1, py3_n_in_context)
52 +- else:
53 +- assert_equal(len(mod_warns), n_in_context)
54 ++ # Python 3 adds a 'version' entry to the registry,
55 ++ # do not count it.
56 ++ num_warns -= 1
57 ++
58 ++ # Behavior of warnings is Python version dependent. Adjust the
59 ++ # expected result to compensate. In particular, Python 3.7 does
60 ++ # not make an entry for ignored warnings.
61 ++ if sys.version_info[:2] >= (3, 7):
62 ++ if py37 is not None:
63 ++ n_in_context = py37
64 ++ elif sys.version_info[:2] >= (3, 4):
65 ++ if py34 is not None:
66 ++ n_in_context = py34
67 ++ assert_equal(num_warns, n_in_context)
68 +
69 +
70 + def _get_fresh_mod():
71 +@@ -1134,6 +1144,8 @@ def _get_fresh_mod():
72 + try:
73 + my_mod.__warningregistry__.clear()
74 + except AttributeError:
75 ++ # will not have a __warningregistry__ unless warning has been
76 ++ # raised in the module at some point
77 + pass
78 + return my_mod
79 +
80 +@@ -1147,21 +1159,23 @@ def test_clear_and_catch_warnings():
81 + warnings.warn('Some warning')
82 + assert_equal(my_mod.__warningregistry__, {})
83 + # Without specified modules, don't clear warnings during context
84 ++ # Python 3.7 catch_warnings doesn't make an entry for 'ignore'.
85 + with clear_and_catch_warnings():
86 + warnings.simplefilter('ignore')
87 + warnings.warn('Some warning')
88 +- assert_warn_len_equal(my_mod, 1)
89 ++ assert_warn_len_equal(my_mod, 1, py37=0)
90 + # Confirm that specifying module keeps old warning, does not add new
91 + with clear_and_catch_warnings(modules=[my_mod]):
92 + warnings.simplefilter('ignore')
93 + warnings.warn('Another warning')
94 +- assert_warn_len_equal(my_mod, 1)
95 ++ assert_warn_len_equal(my_mod, 1, py37=0)
96 + # Another warning, no module spec does add to warnings dict, except on
97 + # Python 3.4 (see comments in `assert_warn_len_equal`)
98 ++ # Python 3.7 catch_warnings doesn't make an entry for 'ignore'.
99 + with clear_and_catch_warnings():
100 + warnings.simplefilter('ignore')
101 + warnings.warn('Another warning')
102 +- assert_warn_len_equal(my_mod, 2, 1)
103 ++ assert_warn_len_equal(my_mod, 2, py34=1, py37=0)
104 +
105 +
106 + def test_suppress_warnings_module():
107 +@@ -1178,6 +1192,7 @@ def test_suppress_warnings_module():
108 + np.apply_along_axis(warn, 0, [0])
109 +
110 + # Test module based warning suppression:
111 ++ assert_warn_len_equal(my_mod, 0)
112 + with suppress_warnings() as sup:
113 + sup.record(UserWarning)
114 + # suppress warning from other module (may have .pyc ending),
115 +@@ -1189,8 +1204,7 @@ def test_suppress_warnings_module():
116 + # got filtered)
117 + assert_(len(sup.log) == 1)
118 + assert_(sup.log[0].message.args[0] == "Some warning")
119 +-
120 +- assert_warn_len_equal(my_mod, 0)
121 ++ assert_warn_len_equal(my_mod, 0, py37=0)
122 + sup = suppress_warnings()
123 + # Will have to be changed if apply_along_axis is moved:
124 + sup.filter(module=my_mod)
125 +@@ -1204,11 +1218,11 @@ def test_suppress_warnings_module():
126 + assert_warn_len_equal(my_mod, 0)
127 +
128 + # Without specified modules, don't clear warnings during context
129 ++ # Python 3.7 does not add ignored warnings.
130 + with suppress_warnings():
131 + warnings.simplefilter('ignore')
132 + warnings.warn('Some warning')
133 +- assert_warn_len_equal(my_mod, 1)
134 +-
135 ++ assert_warn_len_equal(my_mod, 1, py37=0)
136 +
137 + def test_suppress_warnings_type():
138 + # Initial state of module, no warnings
139 +@@ -1232,10 +1246,11 @@ def test_suppress_warnings_type():
140 + assert_warn_len_equal(my_mod, 0)
141 +
142 + # Without specified modules, don't clear warnings during context
143 ++ # Python 3.7 does not add ignored warnings.
144 + with suppress_warnings():
145 + warnings.simplefilter('ignore')
146 + warnings.warn('Some warning')
147 +- assert_warn_len_equal(my_mod, 1)
148 ++ assert_warn_len_equal(my_mod, 1, py37=0)
149 +
150 +
151 + def test_suppress_warnings_decorate_no_record():
152 +--
153 +2.18.0
154 +
155
156 diff --git a/dev-python/numpy/numpy-1.14.5.ebuild b/dev-python/numpy/numpy-1.14.5.ebuild
157 index 507ae3a8210..33db9fa991f 100644
158 --- a/dev-python/numpy/numpy-1.14.5.ebuild
159 +++ b/dev-python/numpy/numpy-1.14.5.ebuild
160 @@ -36,6 +36,8 @@ DEPEND="${RDEPEND}
161
162 PATCHES=(
163 "${FILESDIR}"/${PN}-1.14.5-no-hardcode-blas.patch
164 + # backport a fix for py3.7 test failures
165 + "${FILESDIR}"/numpy-1.14.5-py37.patch
166 )
167
168 src_unpack() {