Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions Lib/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import random
import signal
import sys
import sysconfig
import textwrap
import threading
import time
Expand All @@ -43,7 +44,6 @@
from test.support import os_helper
from test.support import threading_helper
from test.support import warnings_helper
from test.support import skip_if_sanitizer
from test.support.os_helper import FakePath

import codecs
Expand All @@ -66,6 +66,17 @@ def byteslike(*pos, **kw):
class EmptyStruct(ctypes.Structure):
pass

_cflags = sysconfig.get_config_var('CFLAGS') or ''
_config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
MEMORY_SANITIZER = (
'-fsanitize=memory' in _cflags or
'--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)
Expand Down Expand Up @@ -1549,7 +1560,7 @@ class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
tp = io.BufferedReader

@unittest.skip("TODO: RUSTPYTHON, fallible allocation")
@skip_if_sanitizer(memory=True, address=True, reason= "sanitizer 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)
Expand Down Expand Up @@ -1931,7 +1942,7 @@ class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
tp = io.BufferedWriter

@unittest.skip("TODO: RUSTPYTHON, fallible allocation")
@skip_if_sanitizer(memory=True, address=True, reason= "sanitizer 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)
Expand Down Expand Up @@ -2438,7 +2449,7 @@ class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
tp = io.BufferedRandom

@unittest.skip("TODO: RUSTPYTHON, fallible allocation")
@skip_if_sanitizer(memory=True, address=True, reason= "sanitizer 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)
Expand Down