mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-40928: notify users running test_decimal on macOS of malloc warnings (GH-26783)
* When trying to allocate very large regions on macOS, malloc does not fail silently. It sends a noisy error out to STDERR * This provides a helper function to warn the user, and provides the warning for test_decimal, which consistently generates these warnings on macOS. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
4d77691172
commit
15d3c14df3
3 changed files with 26 additions and 1 deletions
|
@ -467,6 +467,24 @@ TEST_HOME_DIR = os.path.dirname(TEST_SUPPORT_DIR)
|
|||
TEST_DATA_DIR = os.path.join(TEST_HOME_DIR, "data")
|
||||
|
||||
|
||||
def darwin_malloc_err_warning(test_name):
|
||||
"""Assure user that loud errors generated by macOS libc's malloc are
|
||||
expected."""
|
||||
if sys.platform != 'darwin':
|
||||
return
|
||||
|
||||
import shutil
|
||||
msg = ' NOTICE '
|
||||
detail = (f'{test_name} may generate "malloc can\'t allocate region"\n'
|
||||
'warnings on macOS systems. This behavior is known. Do not\n'
|
||||
'report a bug unless tests are also failing. See bpo-40928.')
|
||||
|
||||
padding, _ = shutil.get_terminal_size()
|
||||
print(msg.center(padding, '-'))
|
||||
print(detail)
|
||||
print('-' * padding)
|
||||
|
||||
|
||||
def findfile(filename, subdir=None):
|
||||
"""Try to find a file on sys.path or in the test directory. If it is not
|
||||
found the argument passed to the function is returned (this does not
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue