posix.copyfile does not exist on Tiger. Python 3.8's posix._fcopyfile implementation unconditionally uses , which only exists on Leopard ane newer. This patch removes posix._fcopyfile on Tiger - this is okay because the rest of the stdlib uses posix._fcopyfile only conditionally after checking that the function exists (non-Apple systems don't have posix._fcopyfile either). thanks to @dgelessus https://github.com/macports/macports-ports/pull/5987 diff --git Lib/test/test_shutil.py Lib/test/test_shutil.py index e56b337..fdc53e3 100644 --- Lib/test/test_shutil.py +++ Lib/test/test_shutil.py @@ -2468,7 +2468,7 @@ class TestZeroCopySendfile(_ZeroCopyFileTest, unittest.TestCase): shutil._USE_CP_SENDFILE = True -@unittest.skipIf(not MACOS, 'macOS only') +@unittest.skipIf(not MACOS or not hasattr(posix, "_fcopyfile"), 'macOS with posix._fcopyfile only') class TestZeroCopyMACOS(_ZeroCopyFileTest, unittest.TestCase): PATCHPOINT = "posix._fcopyfile" diff --git Modules/clinic/posixmodule.c.h Modules/clinic/posixmodule.c.h index 41baa45..3965876 100644 --- Modules/clinic/posixmodule.c.h +++ Modules/clinic/posixmodule.c.h @@ -5505,7 +5505,7 @@ exit: #endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) */ -#if defined(__APPLE__) +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 PyDoc_STRVAR(os__fcopyfile__doc__, "_fcopyfile($module, in_fd, out_fd, flags, /)\n" diff --git Modules/posixmodule.c Modules/posixmodule.c index 01e8bcb..ff7fb30 100644 --- Modules/posixmodule.c +++ Modules/posixmodule.c @@ -56,6 +56,8 @@ */ #if defined(__APPLE__) +#include + #if defined(__has_builtin) #if __has_builtin(__builtin_available) #define HAVE_BUILTIN_AVAILABLE 1 @@ -224,7 +226,7 @@ corresponding Unix manual entries for more information on calls."); # include #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 # include #endif @@ -9905,7 +9907,7 @@ done: #endif /* HAVE_SENDFILE */ -#if defined(__APPLE__) +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 /*[clinic input] os._fcopyfile @@ -15110,7 +15112,7 @@ all_ins(PyObject *m) #endif #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 if (PyModule_AddIntConstant(m, "_COPYFILE_DATA", COPYFILE_DATA)) return -1; #endif