28
28
import random
29
29
import signal
30
30
import sys
31
- import sysconfig
32
31
import textwrap
33
32
import threading
34
33
import time
44
43
from test .support import os_helper
45
44
from test .support import threading_helper
46
45
from test .support import warnings_helper
46
+ from test .support import skip_if_sanitizer
47
47
from test .support .os_helper import FakePath
48
48
49
49
import codecs
@@ -66,17 +66,6 @@ def byteslike(*pos, **kw):
66
66
class EmptyStruct (ctypes .Structure ):
67
67
pass
68
68
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
-
80
69
# Does io.IOBase finalizer log the exception if the close() method fails?
81
70
# The exception is ignored silently by default in release build.
82
71
IOBASE_EMITS_UNRAISABLE = (hasattr (sys , "gettotalrefcount" ) or sys .flags .dev_mode )
@@ -1550,8 +1539,8 @@ def test_truncate_on_read_only(self):
1550
1539
class CBufferedReaderTest (BufferedReaderTest , SizeofTest ):
1551
1540
tp = io .BufferedReader
1552
1541
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." )
1555
1544
def test_constructor (self ):
1556
1545
BufferedReaderTest .test_constructor (self )
1557
1546
# The allocation can succeed on 32-bit builds, e.g. with more
@@ -1915,8 +1904,8 @@ def test_slow_close_from_thread(self):
1915
1904
class CBufferedWriterTest (BufferedWriterTest , SizeofTest ):
1916
1905
tp = io .BufferedWriter
1917
1906
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." )
1920
1909
def test_constructor (self ):
1921
1910
BufferedWriterTest .test_constructor (self )
1922
1911
# The allocation can succeed on 32-bit builds, e.g. with more
@@ -2414,8 +2403,8 @@ def test_interleaved_readline_write(self):
2414
2403
class CBufferedRandomTest (BufferedRandomTest , SizeofTest ):
2415
2404
tp = io .BufferedRandom
2416
2405
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." )
2419
2408
def test_constructor (self ):
2420
2409
BufferedRandomTest .test_constructor (self )
2421
2410
# The allocation can succeed on 32-bit builds, e.g. with more
0 commit comments