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:
Jack DeVries 2021-08-06 08:50:56 -04:00 committed by GitHub
parent 4d77691172
commit 15d3c14df3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View file

@ -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