|
28 | 28 | import random
|
29 | 29 | import signal
|
30 | 30 | import sys
|
| 31 | +import sysconfig |
31 | 32 | import threading
|
32 | 33 | import time
|
33 | 34 | import unittest
|
@@ -59,6 +60,13 @@ def byteslike(*pos, **kw):
|
59 | 60 | class EmptyStruct(ctypes.Structure):
|
60 | 61 | pass
|
61 | 62 |
|
| 63 | +_cflags = sysconfig.get_config_var('CFLAGS') or '' |
| 64 | +_config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' |
| 65 | +MEMORY_SANITIZER = ( |
| 66 | + '-fsanitize=memory' in _cflags or |
| 67 | + '--with-memory-sanitizer' in _config_args |
| 68 | +) |
| 69 | + |
62 | 70 | def _default_chunk_size():
|
63 | 71 | """Get the default TextIOWrapper chunk size"""
|
64 | 72 | with open(__file__, "r", encoding="latin-1") as f:
|
@@ -1496,6 +1504,8 @@ def test_read_on_closed(self):
|
1496 | 1504 | class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
|
1497 | 1505 | tp = io.BufferedReader
|
1498 | 1506 |
|
| 1507 | + @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing " |
| 1508 | + "instead of returning NULL for malloc failure.") |
1499 | 1509 | def test_constructor(self):
|
1500 | 1510 | BufferedReaderTest.test_constructor(self)
|
1501 | 1511 | # The allocation can succeed on 32-bit builds, e.g. with more
|
@@ -1840,6 +1850,8 @@ def test_slow_close_from_thread(self):
|
1840 | 1850 | class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
|
1841 | 1851 | tp = io.BufferedWriter
|
1842 | 1852 |
|
| 1853 | + @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing " |
| 1854 | + "instead of returning NULL for malloc failure.") |
1843 | 1855 | def test_constructor(self):
|
1844 | 1856 | BufferedWriterTest.test_constructor(self)
|
1845 | 1857 | # The allocation can succeed on 32-bit builds, e.g. with more
|
@@ -2314,6 +2326,8 @@ def test_interleaved_readline_write(self):
|
2314 | 2326 | class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
|
2315 | 2327 | tp = io.BufferedRandom
|
2316 | 2328 |
|
| 2329 | + @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing " |
| 2330 | + "instead of returning NULL for malloc failure.") |
2317 | 2331 | def test_constructor(self):
|
2318 | 2332 | BufferedRandomTest.test_constructor(self)
|
2319 | 2333 | # The allocation can succeed on 32-bit builds, e.g. with more
|
|
0 commit comments