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
40
39
from test import support
41
40
from test .support .script_helper import (
42
41
assert_python_ok , assert_python_failure , run_python_until_end )
43
- from test .support import FakePath
42
+ from test .support import FakePath , skip_if_sanitizer
44
43
45
44
import codecs
46
45
import io # C implementation of io
@@ -62,17 +61,6 @@ def byteslike(*pos, **kw):
62
61
class EmptyStruct (ctypes .Structure ):
63
62
pass
64
63
65
- _cflags = sysconfig .get_config_var ('CFLAGS' ) or ''
66
- _config_args = sysconfig .get_config_var ('CONFIG_ARGS' ) or ''
67
- MEMORY_SANITIZER = (
68
- '-fsanitize=memory' in _cflags or
69
- '--with-memory-sanitizer' in _config_args
70
- )
71
-
72
- ADDRESS_SANITIZER = (
73
- '-fsanitize=address' in _cflags
74
- )
75
-
76
64
# Does io.IOBase finalizer log the exception if the close() method fails?
77
65
# The exception is ignored silently by default in release build.
78
66
IOBASE_EMITS_UNRAISABLE = (hasattr (sys , "gettotalrefcount" ) or sys .flags .dev_mode )
@@ -1543,8 +1531,8 @@ def test_truncate_on_read_only(self):
1543
1531
class CBufferedReaderTest (BufferedReaderTest , SizeofTest ):
1544
1532
tp = io .BufferedReader
1545
1533
1546
- @unittest . skipIf ( MEMORY_SANITIZER or ADDRESS_SANITIZER , "sanitizer defaults to crashing "
1547
- "instead of returning NULL for malloc failure." )
1534
+ @skip_if_sanitizer ( memory = True , address = True , reason = "sanitizer defaults to crashing "
1535
+ "instead of returning NULL for malloc failure." )
1548
1536
def test_constructor (self ):
1549
1537
BufferedReaderTest .test_constructor (self )
1550
1538
# The allocation can succeed on 32-bit builds, e.g. with more
@@ -1892,8 +1880,8 @@ def test_slow_close_from_thread(self):
1892
1880
class CBufferedWriterTest (BufferedWriterTest , SizeofTest ):
1893
1881
tp = io .BufferedWriter
1894
1882
1895
- @unittest . skipIf ( MEMORY_SANITIZER or ADDRESS_SANITIZER , "sanitizer defaults to crashing "
1896
- "instead of returning NULL for malloc failure." )
1883
+ @skip_if_sanitizer ( memory = True , address = True , reason = "sanitizer defaults to crashing "
1884
+ "instead of returning NULL for malloc failure." )
1897
1885
def test_constructor (self ):
1898
1886
BufferedWriterTest .test_constructor (self )
1899
1887
# The allocation can succeed on 32-bit builds, e.g. with more
@@ -2391,8 +2379,8 @@ def test_interleaved_readline_write(self):
2391
2379
class CBufferedRandomTest (BufferedRandomTest , SizeofTest ):
2392
2380
tp = io .BufferedRandom
2393
2381
2394
- @unittest . skipIf ( MEMORY_SANITIZER or ADDRESS_SANITIZER , "sanitizer defaults to crashing "
2395
- "instead of returning NULL for malloc failure." )
2382
+ @skip_if_sanitizer ( memory = True , address = True , reason = "sanitizer defaults to crashing "
2383
+ "instead of returning NULL for malloc failure." )
2396
2384
def test_constructor (self ):
2397
2385
BufferedRandomTest .test_constructor (self )
2398
2386
# The allocation can succeed on 32-bit builds, e.g. with more
0 commit comments