2828import random
2929import signal
3030import sys
31- import sysconfig
3231import textwrap
3332import threading
3433import time
4443from test .support import os_helper
4544from test .support import threading_helper
4645from test .support import warnings_helper
46+ from test .support import skip_if_sanitizer
4747from test .support .os_helper import FakePath
4848
4949import codecs
@@ -66,17 +66,6 @@ def byteslike(*pos, **kw):
6666 class EmptyStruct (ctypes .Structure ):
6767 pass
6868
69- _cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
70- _config_args = sysconfig .get_config_var ('CONFIG_ARGS' ) or ''
71- MEMORY_SANITIZER = (
72- '-fsanitize=memory' in _cflags or
73- '--with-memory-sanitizer' in _config_args
74- )
75-
76- ADDRESS_SANITIZER = (
77- '-fsanitize=address' in _cflags
78- )
79-
8069# Does io.IOBase finalizer log the exception if the close() method fails?
8170# The exception is ignored silently by default in release build.
8271IOBASE_EMITS_UNRAISABLE = (hasattr (sys , "gettotalrefcount" ) or sys .flags .dev_mode )
@@ -1550,8 +1539,8 @@ def test_truncate_on_read_only(self):
15501539class CBufferedReaderTest (BufferedReaderTest , SizeofTest ):
15511540 tp = io .BufferedReader
15521541
1553- @unittest . skipIf ( MEMORY_SANITIZER or ADDRESS_SANITIZER , "sanitizer defaults to crashing "
1554- "instead of returning NULL for malloc failure." )
1542+ @skip_if_sanitizer ( memory = True , address = True , reason = "sanitizer defaults to crashing "
1543+ "instead of returning NULL for malloc failure." )
15551544 def test_constructor (self ):
15561545 BufferedReaderTest .test_constructor (self )
15571546 # The allocation can succeed on 32-bit builds, e.g. with more
@@ -1915,8 +1904,8 @@ def test_slow_close_from_thread(self):
19151904class CBufferedWriterTest (BufferedWriterTest , SizeofTest ):
19161905 tp = io .BufferedWriter
19171906
1918- @unittest . skipIf ( MEMORY_SANITIZER or ADDRESS_SANITIZER , "sanitizer defaults to crashing "
1919- "instead of returning NULL for malloc failure." )
1907+ @skip_if_sanitizer ( memory = True , address = True , reason = "sanitizer defaults to crashing "
1908+ "instead of returning NULL for malloc failure." )
19201909 def test_constructor (self ):
19211910 BufferedWriterTest .test_constructor (self )
19221911 # The allocation can succeed on 32-bit builds, e.g. with more
@@ -2414,8 +2403,8 @@ def test_interleaved_readline_write(self):
24142403class CBufferedRandomTest (BufferedRandomTest , SizeofTest ):
24152404 tp = io .BufferedRandom
24162405
2417- @unittest . skipIf ( MEMORY_SANITIZER or ADDRESS_SANITIZER , "sanitizer defaults to crashing "
2418- "instead of returning NULL for malloc failure." )
2406+ @skip_if_sanitizer ( memory = True , address = True , reason = "sanitizer defaults to crashing "
2407+ "instead of returning NULL for malloc failure." )
24192408 def test_constructor (self ):
24202409 BufferedRandomTest .test_constructor (self )
24212410 # The allocation can succeed on 32-bit builds, e.g. with more
0 commit comments