summaryrefslogtreecommitdiff
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorjunyixie <xiejunyi.arch@bytedance.com>2021-09-15 02:31:50 +0800
committerGitHub <noreply@github.com>2021-09-14 11:31:50 -0700
commitb668cdfa09e9bdfcfddaadd23dbd455d5f667383 (patch)
treec5815c96710fe27a863684c2aa81a0c9140a30f5 /Lib/test/test_decimal.py
parent024fda47d40b8cee77ac1cd3d31ee549edc11986 (diff)
downloadcpython-git-b668cdfa09e9bdfcfddaadd23dbd455d5f667383.tar.gz
bpo-45196: prevent unittest crash on address sanitizer builds (GH-28331)
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 28d56909b3..99263bb13b 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -43,6 +43,17 @@ from test.support import warnings_helper
import random
import inspect
import threading
+import sysconfig
+_cflags = sysconfig.get_config_var('CFLAGS') or ''
+_config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
+MEMORY_SANITIZER = (
+ '-fsanitize=memory' in _cflags or
+ '--with-memory-sanitizer' in _config_args
+)
+
+ADDRESS_SANITIZER = (
+ '-fsanitize=address' in _cflags
+)
if sys.platform == 'darwin':
@@ -5500,6 +5511,8 @@ class CWhitebox(unittest.TestCase):
# Issue 41540:
@unittest.skipIf(sys.platform.startswith("aix"),
"AIX: default ulimit: test is flaky because of extreme over-allocation")
+ @unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
+ "instead of returning NULL for malloc failure.")
def test_maxcontext_exact_arith(self):
# Make sure that exact operations do not raise MemoryError due