-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-no-copyfile-on-Tiger.diff
77 lines (58 loc) · 2.45 KB
/
patch-no-copyfile-on-Tiger.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
posix.copyfile does not exist on Tiger.
Python 3.8's posix._fcopyfile implementation unconditionally uses <copyfile.h>,
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
@@ -2451,7 +2451,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"
--- Modules/posixmodule.c.orig 2021-12-07 05:23:39.000000000 +1100
+++ Modules/posixmodule.c 2021-12-12 04:17:03.000000000 +1100
@@ -63,6 +63,8 @@
*/
#if defined(__APPLE__)
+#include <AvailabilityMacros.h>
+
#if defined(__has_builtin)
#if __has_builtin(__builtin_available)
#define HAVE_BUILTIN_AVAILABLE 1
@@ -231,7 +233,7 @@ corresponding Unix manual entries for mo
# include <sys/sendfile.h>
#endif
-#if defined(__APPLE__)
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
# include <copyfile.h>
#endif
@@ -9990,7 +9992,7 @@ done:
#endif /* HAVE_SENDFILE */
-#if defined(__APPLE__)
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
/*[clinic input]
os._fcopyfile
@@ -15397,7 +15399,7 @@ all_ins(PyObject *m)
if (PyModule_AddIntMacro(m, EFD_SEMAPHORE)) return -1;
#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