Skip to content

Commit 8fa0570

Browse files
authored
Merge pull request RustPython#3827 from deantvv/test-io-3-10
test: update test_io.py to 3.10
2 parents 6ad0e54 + 7496845 commit 8fa0570

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Lib/test/test_io.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import random
2929
import signal
3030
import sys
31+
import sysconfig
3132
import textwrap
3233
import threading
3334
import time
@@ -43,7 +44,6 @@
4344
from test.support import os_helper
4445
from test.support import threading_helper
4546
from test.support import warnings_helper
46-
from test.support import skip_if_sanitizer
4747
from test.support.os_helper import FakePath
4848

4949
import codecs
@@ -66,6 +66,17 @@ 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+
6980
# Does io.IOBase finalizer log the exception if the close() method fails?
7081
# The exception is ignored silently by default in release build.
7182
IOBASE_EMITS_UNRAISABLE = (hasattr(sys, "gettotalrefcount") or sys.flags.dev_mode)
@@ -1549,7 +1560,7 @@ class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
15491560
tp = io.BufferedReader
15501561

15511562
@unittest.skip("TODO: RUSTPYTHON, fallible allocation")
1552-
@skip_if_sanitizer(memory=True, address=True, reason= "sanitizer defaults to crashing "
1563+
@unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
15531564
"instead of returning NULL for malloc failure.")
15541565
def test_constructor(self):
15551566
BufferedReaderTest.test_constructor(self)
@@ -1931,7 +1942,7 @@ class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
19311942
tp = io.BufferedWriter
19321943

19331944
@unittest.skip("TODO: RUSTPYTHON, fallible allocation")
1934-
@skip_if_sanitizer(memory=True, address=True, reason= "sanitizer defaults to crashing "
1945+
@unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
19351946
"instead of returning NULL for malloc failure.")
19361947
def test_constructor(self):
19371948
BufferedWriterTest.test_constructor(self)
@@ -2438,7 +2449,7 @@ class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
24382449
tp = io.BufferedRandom
24392450

24402451
@unittest.skip("TODO: RUSTPYTHON, fallible allocation")
2441-
@skip_if_sanitizer(memory=True, address=True, reason= "sanitizer defaults to crashing "
2452+
@unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
24422453
"instead of returning NULL for malloc failure.")
24432454
def test_constructor(self):
24442455
BufferedRandomTest.test_constructor(self)

0 commit comments

Comments
 (0)