From 7c3e16472ad0803efe90466c6a9757b17c7903e4 Mon Sep 17 00:00:00 2001 From: mattip Date: Wed, 14 Oct 2020 09:42:58 +0300 Subject: [PATCH 1/4] BUG: detect buggy windows version and raise at import --- numpy/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/numpy/__init__.py b/numpy/__init__.py index 3e5277318a47..0aefbcb907b6 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -357,6 +357,26 @@ def _mac_os_check(): raise RuntimeError(msg) del _mac_os_check + def _win_os_check(): + """ + Quick Sanity check for Windows OS: look for fmod bug issue 16744. + """ + try: + a = np.arange(13 * 13, dtype=np.float64).reshape(13, 13) + a = a % 17 # calls fmod + np.linalg.eig(a) + except: + msg = ("The current Numpy installation ({!r}) fails to " + "pass a sanity check due to a bug in the windows runtime. " + "See this issue for more information " + "https://developercommunity.visualstudio.com/content/problem/1208774/fpu-exception-in-fmod0-x-in-windows-10-version-200.html") + raise RuntimeError(msg.format(__file__)) from None + + if sys.platform == "win32" and sys.maxsize > 2**32: + _win_os_check() + + del _mac_os_check + # We usually use madvise hugepages support, but on some old kernels it # is slow and thus better avoided. # Specifically kernel version 4.6 had a bug fix which probably fixed this: From 4583b1cfa54c71aa6c214fd0f7ab8cd5fe75eebd Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Wed, 14 Oct 2020 13:27:24 +0300 Subject: [PATCH 2/4] Update numpy/__init__.py Co-authored-by: Eric Wieser --- numpy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/__init__.py b/numpy/__init__.py index 0aefbcb907b6..90144af3d70e 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -375,7 +375,7 @@ def _win_os_check(): if sys.platform == "win32" and sys.maxsize > 2**32: _win_os_check() - del _mac_os_check + del _win_os_check # We usually use madvise hugepages support, but on some old kernels it # is slow and thus better avoided. From 536f8976d82050171833e4f21b2b5c6b88c22aa8 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Wed, 14 Oct 2020 13:27:36 +0300 Subject: [PATCH 3/4] Update numpy/__init__.py Co-authored-by: Eric Wieser --- numpy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/__init__.py b/numpy/__init__.py index 90144af3d70e..43e7ccf5b441 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -365,7 +365,7 @@ def _win_os_check(): a = np.arange(13 * 13, dtype=np.float64).reshape(13, 13) a = a % 17 # calls fmod np.linalg.eig(a) - except: + except Exception: msg = ("The current Numpy installation ({!r}) fails to " "pass a sanity check due to a bug in the windows runtime. " "See this issue for more information " From a89eb0f58b570b3807969a9c975aecfd086dafb2 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Wed, 14 Oct 2020 17:04:05 +0300 Subject: [PATCH 4/4] fix namespace typos --- numpy/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/__init__.py b/numpy/__init__.py index 43e7ccf5b441..64c658ca3caa 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -362,9 +362,9 @@ def _win_os_check(): Quick Sanity check for Windows OS: look for fmod bug issue 16744. """ try: - a = np.arange(13 * 13, dtype=np.float64).reshape(13, 13) + a = arange(13 * 13, dtype= float64).reshape(13, 13) a = a % 17 # calls fmod - np.linalg.eig(a) + linalg.eig(a) except Exception: msg = ("The current Numpy installation ({!r}) fails to " "pass a sanity check due to a bug in the windows runtime. "