summaryrefslogtreecommitdiff
path: root/Lib/test/test_io.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_io.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_io.py')
-rw-r--r--Lib/test/test_io.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index d1e3b68cc8..3619e749d1 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -73,6 +73,10 @@ MEMORY_SANITIZER = (
'--with-memory-sanitizer' in _config_args
)
+ADDRESS_SANITIZER = (
+ '-fsanitize=address' in _cflags
+)
+
# Does io.IOBase finalizer log the exception if the close() method fails?
# The exception is ignored silently by default in release build.
IOBASE_EMITS_UNRAISABLE = (hasattr(sys, "gettotalrefcount") or sys.flags.dev_mode)
@@ -1546,7 +1550,7 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
tp = io.BufferedReader
- @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing "
+ @unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
"instead of returning NULL for malloc failure.")
def test_constructor(self):
BufferedReaderTest.test_constructor(self)
@@ -1911,7 +1915,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
tp = io.BufferedWriter
- @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing "
+ @unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
"instead of returning NULL for malloc failure.")
def test_constructor(self):
BufferedWriterTest.test_constructor(self)
@@ -2410,7 +2414,7 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
tp = io.BufferedRandom
- @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing "
+ @unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
"instead of returning NULL for malloc failure.")
def test_constructor(self):
BufferedRandomTest.test_constructor(self)