diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index f044358dcbd40f9..115a187a8a85882 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -6310,6 +6310,8 @@ def test_resource_tracker_sigint(self): # Catchable signal (ignored by semaphore tracker) self.check_resource_tracker_death(signal.SIGINT, False) + @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), + 'need signal.pthread_sigmask') def test_resource_tracker_sigterm(self): # Catchable signal (ignored by semaphore tracker) self.check_resource_tracker_death(signal.SIGTERM, False) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 87082ff37d1e58d..62804e2fa2d68e9 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2806,6 +2806,10 @@ def exceeds_recursion_limit(): is_s390x = hasattr(os, 'uname') and os.uname().machine == 's390x' skip_on_s390x = unittest.skipIf(is_s390x, 'skipped on s390x') +# Cygwin uses the newlib C library +skip_on_newlib = unittest.skipIf(sys.platform == 'cygwin', + 'the test fails on newlib C library') + Py_TRACE_REFS = hasattr(sys, 'getobjects') _JIT_ENABLED = sys._jit.is_enabled() diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 8f9a239bead1309..7c40f9f94c37ad9 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -922,6 +922,7 @@ def testHypot(self): @requires_IEEE_754 @unittest.skipIf(HAVE_DOUBLE_ROUNDING, "hypot() loses accuracy on machines with double rounding") + @support.skip_on_newlib def testHypotAccuracy(self): # Verify improved accuracy in cases that were known to be inaccurate. # @@ -1253,12 +1254,6 @@ def testLog2(self): self.assertEqual(math.log2(4), 2.0) self.assertEqual(math.log2(MyIndexable(4)), 2.0) - # Large integer values - self.assertEqual(math.log2(2**1023), 1023.0) - self.assertEqual(math.log2(2**1024), 1024.0) - self.assertEqual(math.log2(2**2000), 2000.0) - self.assertEqual(math.log2(MyIndexable(2**2000)), 2000.0) - self.assertRaises(ValueError, math.log2, 0.0) self.assertRaises(ValueError, math.log2, 0) self.assertRaises(ValueError, math.log2, MyIndexable(0)) @@ -1276,12 +1271,19 @@ def testLog2(self): @requires_IEEE_754 # log2() is not accurate enough on Mac OS X Tiger (10.4) @support.requires_mac_ver(10, 5) + @support.skip_on_newlib def testLog2Exact(self): # Check that we get exact equality for log2 of powers of 2. actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)] expected = [float(n) for n in range(-1074, 1024)] self.assertEqual(actual, expected) + # Large integer values + self.assertEqual(math.log2(2**1023), 1023.0) + self.assertEqual(math.log2(2**1024), 1024.0) + self.assertEqual(math.log2(2**2000), 2000.0) + self.assertEqual(math.log2(MyIndexable(2**2000)), 2000.0) + def testLog10(self): self.assertRaises(TypeError, math.log10) self.ftest('log10(0.1)', math.log10(0.1), -1) @@ -2615,6 +2617,7 @@ def test_fma_nan_results(self): self.assertIsNaN(math.fma(a, math.nan, b)) self.assertIsNaN(math.fma(a, b, math.nan)) + @support.skip_on_newlib def test_fma_infinities(self): # Cases involving infinite inputs or results. positives = [1e-300, 2.3, 1e300, math.inf] @@ -2685,7 +2688,7 @@ def test_fma_infinities(self): # gh-73468: On some platforms, libc fma() doesn't implement IEE 754-2008 # properly: it doesn't use the right sign when the result is zero. @unittest.skipIf( - sys.platform.startswith(("freebsd", "wasi", "netbsd", "emscripten")) + sys.platform.startswith(("freebsd", "wasi", "netbsd", "emscripten", "cygwin")) or (sys.platform == "android" and platform.machine() == "x86_64") or support.linked_to_musl(), # gh-131032 f"this platform doesn't implement IEE 754-2008 properly") @@ -2743,6 +2746,7 @@ def test_fma_zero_result(self): self.assertIsNegativeZero(math.fma(y-x, -(x+y), -z)) self.assertIsPositiveZero(math.fma(x-y, -(x+y), z)) + @support.skip_on_newlib def test_fma_overflow(self): a = b = float.fromhex('0x1p512') c = float.fromhex('0x1p1023') @@ -2776,11 +2780,13 @@ def test_fma_overflow(self): c = float.fromhex('0x1.fffffffffffffp+1023') self.assertEqual(math.fma(a, b, -c), c) + @support.skip_on_newlib def test_fma_single_round(self): a = float.fromhex('0x1p-50') self.assertEqual(math.fma(a - 1.0, a + 1.0, 1.0), a*a) - def test_random(self): + @support.skip_on_newlib + def test_fma_random(self): # A collection of randomly generated inputs for which the naive FMA # (with two rounds) gives a different result from a singly-rounded FMA. diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py index 677a87b51b91925..de7d13651cfea62 100644 --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -16,7 +16,7 @@ import sys import unittest from test import support -from test.support import import_helper, requires_IEEE_754 +from test.support import import_helper, requires_IEEE_754, skip_on_newlib from decimal import Decimal from fractions import Fraction @@ -2799,6 +2799,7 @@ def test_sqrtprod_helper_function_fundamentals(self): @unittest.skipIf(HAVE_DOUBLE_ROUNDING, "accuracy not guaranteed on machines with double rounding") @support.cpython_only # Allow for a weaker sumprod() implementation + @skip_on_newlib def test_sqrtprod_helper_function_improved_accuracy(self): # Test a known example where accuracy is improved x, y, target = 0.8035720646477457, 0.7957468097636939, 0.7996498651651661 diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 5ac28870455f4d8..e95cc6db170e243 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -19,6 +19,13 @@ else: glibc_ver = None +def skip_cygwin_locale(): + if sys.platform != 'cygwin': + return + loc = locale.getlocale(locale.LC_TIME)[0] + if loc in ('my_MM', 'or_IN'): + raise unittest.SkipTest('test fails on Cygwin') + class getlang_Tests(unittest.TestCase): """Test _getlang""" @@ -509,6 +516,8 @@ def test_bad_timezone(self): 'my_MM', 'or_IN', 'shn_MM', 'az_IR', 'byn_ER', 'wal_ET', 'lzh_TW') def test_date_time_locale(self): + skip_cygwin_locale() + # Test %c directive loc = locale.getlocale(locale.LC_TIME)[0] if glibc_ver and glibc_ver < (2, 31) and loc == 'br_FR': @@ -536,6 +545,8 @@ def test_date_time_locale(self): 'csb_PL', 'br_FR', 'gez_ET', 'brx_IN', 'my_MM', 'shn_MM') def test_date_time_locale2(self): + skip_cygwin_locale() + # Test %c directive loc = locale.getlocale(locale.LC_TIME)[0] if sys.platform.startswith('sunos'): @@ -550,6 +561,8 @@ def test_date_time_locale2(self): 'he_IL', 'eu_ES', 'ar_AE', 'az_IR', 'my_MM', 'or_IN', 'shn_MM', 'lzh_TW') def test_date_locale(self): + skip_cygwin_locale() + # Test %x directive now = time.time() self.roundtrip('%x', slice(0, 3), time.localtime(now)) @@ -567,6 +580,8 @@ def test_date_locale(self): @run_with_locales('LC_TIME', 'en_US', 'fr_FR', 'de_DE', 'ja_JP', 'eu_ES', 'ar_AE', 'my_MM', 'shn_MM', 'lzh_TW') def test_date_locale2(self): + skip_cygwin_locale() + # Test %x directive loc = locale.getlocale(locale.LC_TIME)[0] if sys.platform.startswith(('sunos', 'aix')): @@ -587,6 +602,8 @@ def test_date_locale2(self): 'ti_ET', 'tig_ER', 'wal_ET', 'lzh_TW', 'ar_SA', 'bg_BG') def test_time_locale(self): + skip_cygwin_locale() + # Test %X directive loc = locale.getlocale(locale.LC_TIME)[0] pos = slice(3, 6) diff --git a/Modules/_remote_debugging/frames.c b/Modules/_remote_debugging/frames.c index 8d8019396b3e31a..d73cd080dc477f3 100644 --- a/Modules/_remote_debugging/frames.c +++ b/Modules/_remote_debugging/frames.c @@ -56,12 +56,14 @@ process_single_stack_chunk( return -1; } - this_chunk = PyMem_RawRealloc(this_chunk, actual_size); - if (!this_chunk) { + char *tmp = PyMem_RawRealloc(this_chunk, actual_size); + if (!tmp) { + PyMem_RawFree(this_chunk); PyErr_NoMemory(); set_exception_cause(unwinder, PyExc_MemoryError, "Failed to reallocate stack chunk buffer"); return -1; } + this_chunk = tmp; if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, chunk_addr, actual_size, this_chunk) < 0) { PyMem_RawFree(this_chunk); diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 25e744d7da25c72..d90bf1f2ef90ed9 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -820,12 +820,15 @@ time_strftime1(time_char **outbuf, size_t *bufsize, PyErr_NoMemory(); return NULL; } - *outbuf = (time_char *)PyMem_Realloc(*outbuf, - *bufsize*sizeof(time_char)); - if (*outbuf == NULL) { + time_char *tmp = (time_char *)PyMem_Realloc(*outbuf, + *bufsize*sizeof(time_char)); + if (tmp == NULL) { + PyMem_Free(*outbuf); + *outbuf = NULL; PyErr_NoMemory(); return NULL; } + *outbuf = tmp; #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__) errno = 0; #endif diff --git a/configure b/configure index 657a7e106675c62..0690e97b142f01c 100755 --- a/configure +++ b/configure @@ -19979,12 +19979,6 @@ if test "x$ac_cv_func_dup" = xyes then : printf "%s\n" "#define HAVE_DUP 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3" -if test "x$ac_cv_func_dup3" = xyes -then : - printf "%s\n" "#define HAVE_DUP3 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "execv" "ac_cv_func_execv" if test "x$ac_cv_func_execv" = xyes @@ -20459,12 +20453,6 @@ if test "x$ac_cv_func_pipe" = xyes then : printf "%s\n" "#define HAVE_PIPE 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" -if test "x$ac_cv_func_pipe2" = xyes -then : - printf "%s\n" "#define HAVE_PIPE2 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "plock" "ac_cv_func_plock" if test "x$ac_cv_func_plock" = xyes @@ -21132,7 +21120,13 @@ fi # header definition prevents usage - autoconf doesn't use the headers), or # raise an error if used at runtime. Force these symbols off. if test "$ac_sys_system" != "iOS" ; then - ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy" + ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3" +if test "x$ac_cv_func_dup3" = xyes +then : + printf "%s\n" "#define HAVE_DUP3 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy" if test "x$ac_cv_func_getentropy" = xyes then : printf "%s\n" "#define HAVE_GETENTROPY 1" >>confdefs.h @@ -21143,6 +21137,12 @@ if test "x$ac_cv_func_getgroups" = xyes then : printf "%s\n" "#define HAVE_GETGROUPS 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" +if test "x$ac_cv_func_pipe2" = xyes +then : + printf "%s\n" "#define HAVE_PIPE2 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "system" "ac_cv_func_system" if test "x$ac_cv_func_system" = xyes diff --git a/configure.ac b/configure.ac index fedd429facbe142..f2fca52c8f3dfc3 100644 --- a/configure.ac +++ b/configure.ac @@ -5402,7 +5402,7 @@ fi AC_CHECK_FUNCS([ \ accept4 alarm bind_textdomain_codeset chmod chown clearenv \ clock closefrom close_range confstr \ - copy_file_range ctermid dladdr dup dup3 execv explicit_bzero explicit_memset \ + copy_file_range ctermid dladdr dup execv explicit_bzero explicit_memset \ faccessat fchmod fchmodat fchown fchownat fdopendir fdwalk fexecve \ fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \ gai_strerror getegid geteuid getgid getgrent getgrgid getgrgid_r \ @@ -5412,7 +5412,7 @@ AC_CHECK_FUNCS([ \ getspnam getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \ lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \ mknod mknodat mktime mmap mremap nice openat opendir pathconf pause pipe \ - pipe2 plock poll ppoll posix_fadvise posix_fallocate posix_openpt posix_spawn posix_spawnp \ + plock poll ppoll posix_fadvise posix_fallocate posix_openpt posix_spawn posix_spawnp \ posix_spawn_file_actions_addclosefrom_np \ pread preadv preadv2 process_vm_readv \ pthread_cond_timedwait_relative_np pthread_condattr_setclock pthread_init \ @@ -5449,7 +5449,7 @@ fi # header definition prevents usage - autoconf doesn't use the headers), or # raise an error if used at runtime. Force these symbols off. if test "$ac_sys_system" != "iOS" ; then - AC_CHECK_FUNCS([getentropy getgroups system]) + AC_CHECK_FUNCS([dup3 getentropy getgroups pipe2 system]) fi AC_CHECK_DECL([dirfd],