forked from flet-dev/python-ios-pre-3.13
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython.patch
More file actions
7458 lines (7110 loc) · 274 KB
/
Python.patch
File metadata and controls
7458 lines (7110 loc) · 274 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 9d206f46ae..51846163d7 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -3160,6 +3160,13 @@
.. versionadded:: 3.8
+.. data:: allows_subprocesses
+
+ Boolean that describes whether subprocesses can be by the operating system.
+ Some platforms (e.g., iOS mobile devices) *implement* calls like
+ :func:`execv` and :func:`spawnv`, but will raise errors or break if
+ called. Calls to create subprocesses should only be invoked if
+ :data:`os.allows_subprocesses` is `True`.
.. data:: MFD_CLOEXEC
MFD_ALLOW_SEALING
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 3150aa6070..d37e0d3a97 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -25,6 +25,11 @@
:pep:`324` -- PEP proposing the subprocess module
+:mod:`subprocess` can only be used on platforms that support subprocess
+creation. Some platforms (especially mobile platforms) may not support
+subprocesses; if :data:`os.allows_subprocesses` is `False`, any calls in
+this module that request a subprocess be created will raise a
+:exc:`RuntimeError`.
Using the :mod:`subprocess` Module
----------------------------------
diff --git a/Include/datetime.h b/Include/datetime.h
index 5d9f2558f9..fc66471923 100644
--- a/Include/datetime.h
+++ b/Include/datetime.h
@@ -179,7 +179,6 @@
#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
-
/* This block is only used as part of the public API and should not be
* included in _datetimemodule.c, which does not use the C API capsule.
* See bpo-35081 for more details.
diff --git a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
index f9d27cb89d..da172b345a 100644
--- a/Lib/ctypes/test/test_as_parameter.py
+++ b/Lib/ctypes/test/test_as_parameter.py
@@ -1,9 +1,11 @@
+import os
import unittest
from ctypes import *
from ctypes.test import need_symbol
import _ctypes_test
-dll = CDLL(_ctypes_test.__file__)
+
+dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
try:
CALLBACK_FUNCTYPE = WINFUNCTYPE
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index 992b8c4da3..e99c3e21a2 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -24,7 +24,7 @@
("R", c_short, 6),
("S", c_short, 7)]
-func = CDLL(_ctypes_test.__file__).unpack_bitfields
+func = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE'])).unpack_bitfields
func.argtypes = POINTER(BITS), c_char
##for n in "ABCDEFGHIMNOPQRS":
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index d8e9c5a760..52820932b0 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -160,7 +160,7 @@
def test_integrate(self):
# Derived from some then non-working code, posted by David Foster
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
# The function prototype called by 'integrate': double func(double);
CALLBACK = CFUNCTYPE(c_double, c_double)
@@ -211,7 +211,7 @@
def test_callback_register_int(self):
# Issue #8275: buggy handling of callback args under Win64
# NOTE: should be run on release builds as well
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
CALLBACK = CFUNCTYPE(c_int, c_int, c_int, c_int, c_int, c_int)
# All this function does is call the callback with its args squared
func = dll._testfunc_cbk_reg_int
@@ -227,7 +227,7 @@
def test_callback_register_double(self):
# Issue #8275: buggy handling of callback args under Win64
# NOTE: should be run on release builds as well
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
CALLBACK = CFUNCTYPE(c_double, c_double, c_double, c_double,
c_double, c_double)
# All this function does is call the callback with its args squared
diff --git a/Lib/ctypes/test/test_cfuncs.py b/Lib/ctypes/test/test_cfuncs.py
index ac2240fa19..b08b5f7581 100644
--- a/Lib/ctypes/test/test_cfuncs.py
+++ b/Lib/ctypes/test/test_cfuncs.py
@@ -1,6 +1,7 @@
# A lot of failures in these tests on Mac OS X.
# Byte order related?
+import os
import unittest
from ctypes import *
from ctypes.test import need_symbol
@@ -8,7 +9,7 @@
import _ctypes_test
class CFunctions(unittest.TestCase):
- _dll = CDLL(_ctypes_test.__file__)
+ _dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
def S(self):
return c_longlong.in_dll(self._dll, "last_tf_arg_s").value
@@ -206,7 +207,7 @@
@need_symbol('WinDLL')
class stdcallCFunctions(CFunctions):
- _dll = stdcall_dll(_ctypes_test.__file__)
+ _dll = stdcall_dll(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_checkretval.py b/Lib/ctypes/test/test_checkretval.py
index e9567dc391..3c3fbf103c 100644
--- a/Lib/ctypes/test/test_checkretval.py
+++ b/Lib/ctypes/test/test_checkretval.py
@@ -1,3 +1,4 @@
+import os
import unittest
from ctypes import *
@@ -14,7 +15,7 @@
def test_checkretval(self):
import _ctypes_test
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
self.assertEqual(42, dll._testfunc_p_p(42))
dll._testfunc_p_p.restype = CHECKED
diff --git a/Lib/ctypes/test/test_funcptr.py b/Lib/ctypes/test/test_funcptr.py
index e0b9b54e97..a5b1b55294 100644
--- a/Lib/ctypes/test/test_funcptr.py
+++ b/Lib/ctypes/test/test_funcptr.py
@@ -1,4 +1,4 @@
-import unittest
+import os, unittest
from ctypes import *
try:
@@ -8,7 +8,10 @@
WINFUNCTYPE = CFUNCTYPE
import _ctypes_test
-lib = CDLL(_ctypes_test.__file__)
+
+
+lib = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
+
class CFuncPtrTestCase(unittest.TestCase):
def test_basic(self):
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index 7562892420..bf8f4dc92c 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -7,6 +7,7 @@
from ctypes import *
from ctypes.test import need_symbol
+import os
import sys, unittest
try:
@@ -16,7 +17,9 @@
WINFUNCTYPE = CFUNCTYPE
import _ctypes_test
-dll = CDLL(_ctypes_test.__file__)
+
+
+dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
if sys.platform == "win32":
windll = WinDLL(_ctypes_test.__file__)
diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
index 56285b5ff8..f78a152ade 100644
--- a/Lib/ctypes/test/test_libc.py
+++ b/Lib/ctypes/test/test_libc.py
@@ -1,9 +1,12 @@
+import os
import unittest
from ctypes import *
import _ctypes_test
-lib = CDLL(_ctypes_test.__file__)
+
+lib = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
+
def three_way_cmp(x, y):
"""Return -1 if x < y, 0 if x == y and 1 if x > y"""
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
index 38af7ac13d..db0d4986d6 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/ctypes/test/test_parameters.py
@@ -140,7 +140,7 @@
import _ctypes_test
from ctypes import CDLL, c_void_p, ArgumentError
- func = CDLL(_ctypes_test.__file__)._testfunc_p_p
+ func = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))._testfunc_p_p
func.restype = c_void_p
# TypeError: has no from_param method
self.assertRaises(TypeError, setattr, func, "argtypes", (object,))
diff --git a/Lib/ctypes/test/test_pickling.py b/Lib/ctypes/test/test_pickling.py
index c4a79b9779..833608b629 100644
--- a/Lib/ctypes/test/test_pickling.py
+++ b/Lib/ctypes/test/test_pickling.py
@@ -1,8 +1,11 @@
import unittest
+import os
import pickle
from ctypes import *
import _ctypes_test
-dll = CDLL(_ctypes_test.__file__)
+
+
+dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
class X(Structure):
_fields_ = [("a", c_int), ("b", c_double)]
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py
index e97515879f..d678be3800 100644
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -1,3 +1,4 @@
+import os
import unittest, sys
from ctypes import *
@@ -20,7 +21,7 @@
self.assertRaises(TypeError, A, c_ulong(33))
def test_pass_pointers(self):
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
func = dll._testfunc_p_p
if sizeof(c_longlong) == sizeof(c_void_p):
func.restype = c_longlong
@@ -38,7 +39,7 @@
self.assertEqual(res[0], 12345678)
def test_change_pointers(self):
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
func = dll._testfunc_p_p
i = c_int(87654)
@@ -77,7 +78,7 @@
return 0
callback = PROTOTYPE(func)
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
# This function expects a function pointer,
# and calls this with an integer pointer as parameter.
# The int pointer points to a table containing the numbers 1..10
@@ -143,7 +144,7 @@
def test_charpp(self):
"""Test that a character pointer-to-pointer is correctly passed"""
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
func = dll._testfunc_c_p_p
func.restype = c_char_p
argv = (c_char_p * 2)()
diff --git a/Lib/ctypes/test/test_prototypes.py b/Lib/ctypes/test/test_prototypes.py
index cd0c649de3..539351f798 100644
--- a/Lib/ctypes/test/test_prototypes.py
+++ b/Lib/ctypes/test/test_prototypes.py
@@ -1,3 +1,4 @@
+import os
from ctypes import *
from ctypes.test import need_symbol
import unittest
@@ -23,7 +24,9 @@
# In this case, there would have to be an additional reference to the argument...
import _ctypes_test
-testdll = CDLL(_ctypes_test.__file__)
+
+
+testdll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
# Return machine address `a` as a (possibly long) non-negative integer.
# Starting with Python 2.5, id(anything) is always non-negative, and
diff --git a/Lib/ctypes/test/test_refcounts.py b/Lib/ctypes/test/test_refcounts.py
index f2edfa6400..0e4dd7c126 100644
--- a/Lib/ctypes/test/test_refcounts.py
+++ b/Lib/ctypes/test/test_refcounts.py
@@ -1,3 +1,4 @@
+import os
import unittest
from test import support
import ctypes
@@ -7,7 +8,10 @@
OtherCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong)
import _ctypes_test
-dll = ctypes.CDLL(_ctypes_test.__file__)
+
+
+dll = ctypes.CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
+
class RefcountTestCase(unittest.TestCase):
diff --git a/Lib/ctypes/test/test_returnfuncptrs.py b/Lib/ctypes/test/test_returnfuncptrs.py
index 1974f40df6..7b76fae44c 100644
--- a/Lib/ctypes/test/test_returnfuncptrs.py
+++ b/Lib/ctypes/test/test_returnfuncptrs.py
@@ -1,5 +1,6 @@
import unittest
from ctypes import *
+import os
import _ctypes_test
@@ -8,7 +9,7 @@
def test_with_prototype(self):
# The _ctypes_test shared lib/dll exports quite some functions for testing.
# The get_strchr function returns a *pointer* to the C strchr function.
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
get_strchr = dll.get_strchr
get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char)
strchr = get_strchr()
@@ -20,7 +21,7 @@
self.assertRaises(TypeError, strchr, b"abcdef")
def test_without_prototype(self):
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
get_strchr = dll.get_strchr
# the default 'c_int' would not work on systems where sizeof(int) != sizeof(void *)
get_strchr.restype = c_void_p
@@ -34,7 +35,7 @@
self.assertRaises(TypeError, strchr, b"abcdef")
def test_from_dll(self):
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
# _CFuncPtr instances are now callable with a tuple argument
# which denotes a function name and a dll:
strchr = CFUNCTYPE(c_char_p, c_char_p, c_char)(("my_strchr", dll))
@@ -50,13 +51,13 @@
if key == 0:
return "my_strchr"
if key == 1:
- return CDLL(_ctypes_test.__file__)
+ return CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
raise IndexError
# _CFuncPtr instances are now callable with a tuple argument
# which denotes a function name and a dll:
strchr = CFUNCTYPE(c_char_p, c_char_p, c_char)(
- BadSequence(("my_strchr", CDLL(_ctypes_test.__file__))))
+ BadSequence(("my_strchr", CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE'])))))
self.assertTrue(strchr(b"abcdef", b"b"), "bcdef")
self.assertEqual(strchr(b"abcdef", b"x"), None)
self.assertRaises(ArgumentError, strchr, b"abcdef", 3.0)
diff --git a/Lib/ctypes/test/test_slicing.py b/Lib/ctypes/test/test_slicing.py
index a3932f1767..6d7bfff8f2 100644
--- a/Lib/ctypes/test/test_slicing.py
+++ b/Lib/ctypes/test/test_slicing.py
@@ -1,3 +1,4 @@
+import os
import unittest
from ctypes import *
from ctypes.test import need_symbol
@@ -62,7 +63,7 @@
def test_char_ptr(self):
s = b"abcdefghijklmnopqrstuvwxyz"
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
dll.my_strdup.restype = POINTER(c_char)
dll.my_free.restype = None
res = dll.my_strdup(s)
@@ -94,7 +95,7 @@
dll.my_free(res)
def test_char_ptr_with_free(self):
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
s = b"abcdefghijklmnopqrstuvwxyz"
class allocated_c_char_p(c_char_p):
@@ -130,7 +131,7 @@
def test_wchar_ptr(self):
s = "abcdefghijklmnopqrstuvwxyz\0"
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
dll.my_wcsdup.restype = POINTER(c_wchar)
dll.my_wcsdup.argtypes = POINTER(c_wchar),
dll.my_free.restype = None
diff --git a/Lib/ctypes/test/test_stringptr.py b/Lib/ctypes/test/test_stringptr.py
index c20951f4ce..fde0eef1c7 100644
--- a/Lib/ctypes/test/test_stringptr.py
+++ b/Lib/ctypes/test/test_stringptr.py
@@ -1,10 +1,12 @@
+import os
import unittest
from test import support
from ctypes import *
import _ctypes_test
-lib = CDLL(_ctypes_test.__file__)
+
+lib = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
class StringPtrTestCase(unittest.TestCase):
diff --git a/Lib/ctypes/test/test_unicode.py b/Lib/ctypes/test/test_unicode.py
index c200af7b65..ea3945d56b 100644
--- a/Lib/ctypes/test/test_unicode.py
+++ b/Lib/ctypes/test/test_unicode.py
@@ -1,3 +1,4 @@
+import os
import unittest
import ctypes
from ctypes.test import need_symbol
@@ -7,7 +8,7 @@
@need_symbol('c_wchar')
class UnicodeTestCase(unittest.TestCase):
def test_wcslen(self):
- dll = ctypes.CDLL(_ctypes_test.__file__)
+ dll = ctypes.CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
wcslen = dll.my_wcslen
wcslen.argtypes = [ctypes.c_wchar_p]
@@ -26,7 +27,7 @@
self.assertEqual(buf[::2], 'a\xe4\xfc')
self.assertEqual(buf[6:5:-1], "")
-func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
+func = ctypes.CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))._testfunc_p_p
class StringTestCase(UnicodeTestCase):
def setUp(self):
diff --git a/Lib/ctypes/test/test_values.py b/Lib/ctypes/test/test_values.py
index 87eb9198ad..e40b82506f 100644
--- a/Lib/ctypes/test/test_values.py
+++ b/Lib/ctypes/test/test_values.py
@@ -2,6 +2,7 @@
A testcase which accesses *values* in a dll.
"""
+import os
import unittest
import sys
from ctypes import *
@@ -13,7 +14,7 @@
def test_an_integer(self):
# This test checks and changes an integer stored inside the
# _ctypes_test dll/shared lib.
- ctdll = CDLL(_ctypes_test.__file__)
+ ctdll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
an_integer = c_int.in_dll(ctdll, "an_integer")
x = an_integer.value
self.assertEqual(x, ctdll.get_an_integer())
@@ -25,7 +26,7 @@
self.assertEqual(x, ctdll.get_an_integer())
def test_undefined(self):
- ctdll = CDLL(_ctypes_test.__file__)
+ ctdll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol")
class PythonValuesTestCase(unittest.TestCase):
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py
index e51bdc8ad6..78ba8e6786 100644
--- a/Lib/ctypes/test/test_win32.py
+++ b/Lib/ctypes/test/test_win32.py
@@ -1,6 +1,7 @@
# Windows specific tests
from ctypes import *
+import os
import unittest, sys
from test import support
@@ -102,7 +103,7 @@
("right", c_long),
("bottom", c_long)]
- dll = CDLL(_ctypes_test.__file__)
+ dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE']))
pt = POINT(15, 25)
left = c_long.in_dll(dll, 'left')
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 0c2510e161..6c3c43f11d 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -67,7 +67,7 @@
return fname
return None
-elif os.name == "posix" and sys.platform == "darwin":
+elif os.name == "posix" and sys.platform in ('darwin', 'ios', 'tvos', 'watchos'):
from ctypes.macholib.dyld import dyld_find as _dyld_find
def find_library(name):
possible = ['lib%s.dylib' % name,
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 808c0dc287..b4813efe0c 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -52,6 +52,8 @@
def build_ext(self, *args, **kwargs):
return build_ext(*args, **kwargs)
+ @unittest.skipUnless(os.name == 'nt' or (os.name == 'posix' and hasattr(os, 'fork') and os.allows_subprocesses),
+ "distutils cannot spawn child processes")
def test_build_ext(self):
cmd = support.missing_compiler_executable()
if cmd is not None:
@@ -328,6 +330,8 @@
cmd.run()
self.assertEqual(cmd.compiler, 'unix')
+ @unittest.skipUnless(os.name == 'nt' or (os.name == 'posix' and hasattr(os, 'fork') and os.allows_subprocesses),
+ "distutils cannot spawn child processes")
def test_get_outputs(self):
cmd = support.missing_compiler_executable()
if cmd is not None:
diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py
index 0712e92c6a..52a0121250 100644
--- a/Lib/distutils/tests/test_build_py.py
+++ b/Lib/distutils/tests/test_build_py.py
@@ -106,6 +106,8 @@
['boiledeggs.%s.pyc' % sys.implementation.cache_tag])
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ @unittest.skipUnless(os.name == 'nt' or (os.name == 'posix' and hasattr(os, 'fork') and os.allows_subprocesses),
+ "distutils cannot spawn child processes")
def test_byte_compile_optimized(self):
project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
os.chdir(project_dir)
diff --git a/Lib/distutils/tests/test_config_cmd.py b/Lib/distutils/tests/test_config_cmd.py
index 9aeab07b46..3c6dfc0439 100644
--- a/Lib/distutils/tests/test_config_cmd.py
+++ b/Lib/distutils/tests/test_config_cmd.py
@@ -38,6 +38,7 @@
self.assertEqual(len(self._logs), numlines+1)
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
+ @unittest.skipUnless(os.allows_subprocesses, 'Test requires support for subprocesses.')
def test_search_cpp(self):
cmd = missing_compiler_executable(['preprocessor'])
if cmd is not None:
diff --git a/Lib/distutils/tests/test_cygwinccompiler.py b/Lib/distutils/tests/test_cygwinccompiler.py
index 9dc869de4c..176a87f8a8 100644
--- a/Lib/distutils/tests/test_cygwinccompiler.py
+++ b/Lib/distutils/tests/test_cygwinccompiler.py
@@ -5,11 +5,14 @@
from io import BytesIO
from test.support import run_unittest
-from distutils import cygwinccompiler
-from distutils.cygwinccompiler import (check_config_h,
- CONFIG_H_OK, CONFIG_H_NOTOK,
- CONFIG_H_UNCERTAIN, get_versions,
- get_msvcr)
+# Importing cygwinccompiler attempts to import other tools
+# that may not exist unless you're on win32.
+if sys.platform == 'win32':
+ from distutils import cygwinccompiler
+ from distutils.cygwinccompiler import (check_config_h,
+ CONFIG_H_OK, CONFIG_H_NOTOK,
+ CONFIG_H_UNCERTAIN, get_versions,
+ get_msvcr)
from distutils.tests import support
class FakePopen(object):
@@ -25,6 +28,7 @@
self.stdout = os.popen(cmd, 'r')
+@unittest.skipUnless(sys.platform == "win32", "These tests are only for win32")
class CygwinCCompilerTestCase(support.TempdirManager,
unittest.TestCase):
@@ -118,7 +122,7 @@
def test_get_msvcr(self):
# none
- sys.version = ('2.6.1 (r261:67515, Dec 6 2008, 16:42:21) '
+ sys.version = ('2.6.1 (r261:67515, Dec 6 2008, 16:42:21) '
'\n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]')
self.assertEqual(get_msvcr(), None)
diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py
index 51c80e0421..11008da5f2 100644
--- a/Lib/distutils/tests/test_install.py
+++ b/Lib/distutils/tests/test_install.py
@@ -197,6 +197,8 @@
'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
self.assertEqual(found, expected)
+ @unittest.skipUnless(os.name == 'nt' or (os.name == 'posix' and hasattr(os, 'fork') and os.allows_subprocesses),
+ "distutils cannot spawn child processes")
def test_record_extensions(self):
cmd = test_support.missing_compiler_executable()
if cmd is not None:
diff --git a/Lib/distutils/tests/test_install_lib.py b/Lib/distutils/tests/test_install_lib.py
index fda6315bbc..63c71a8d46 100644
--- a/Lib/distutils/tests/test_install_lib.py
+++ b/Lib/distutils/tests/test_install_lib.py
@@ -35,6 +35,8 @@
self.assertEqual(cmd.optimize, 2)
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ @unittest.skipUnless(os.name == 'nt' or (os.name == 'posix' and hasattr(os, 'fork') and os.allows_subprocesses),
+ "distutils cannot spawn child processes")
def test_byte_compile(self):
project_dir, dist = self.create_dist()
os.chdir(project_dir)
diff --git a/Lib/distutils/tests/test_spawn.py b/Lib/distutils/tests/test_spawn.py
index ad5038142f..856afe86c1 100644
--- a/Lib/distutils/tests/test_spawn.py
+++ b/Lib/distutils/tests/test_spawn.py
@@ -15,8 +15,8 @@
support.LoggingSilencer,
unittest.TestCase):
- @unittest.skipUnless(os.name in ('nt', 'posix'),
- 'Runs only under posix or nt')
+ @unittest.skipUnless(os.name == 'nt' or (os.name == 'posix' and hasattr(os, 'fork') and os.allows_subprocesses),
+ "distutils cannot spawn child processes")
def test_spawn(self):
tmpdir = self.mkdtemp()
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
index 236755d095..721bc91093 100644
--- a/Lib/distutils/tests/test_sysconfig.py
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -244,6 +244,7 @@
self.assertIsNotNone(vars['SO'])
self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
+ @unittest.skipUnless(os.allows_subprocesses, 'Test requires support for subprocesses.')
def test_customize_compiler_before_get_config_vars(self):
# Issue #21923: test that a Distribution compiler
# instance can be called without an explicit call to
diff --git a/Lib/distutils/tests/test_util.py b/Lib/distutils/tests/test_util.py
index bf0d4333f9..09ba51bcea 100644
--- a/Lib/distutils/tests/test_util.py
+++ b/Lib/distutils/tests/test_util.py
@@ -233,6 +233,8 @@
# XXX platforms to be covered: mac
+ @unittest.skipUnless(os.name == 'nt' or (os.name == 'posix' and hasattr(os, 'fork') and os.allows_subprocesses),
+ "distutils cannot spawn child processes")
def test_check_environ(self):
util._environ_checked = 0
os.environ.pop('HOME', None)
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 25a3f8c0e0..560307ffad 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -21,7 +21,7 @@
# Bootstrap-related code ######################################################
_CASE_INSENSITIVE_PLATFORMS_STR_KEY = 'win',
-_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY = 'cygwin', 'darwin'
+_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY = 'cygwin', 'darwin', 'ios', 'tvos', 'watchos'
_CASE_INSENSITIVE_PLATFORMS = (_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY
+ _CASE_INSENSITIVE_PLATFORMS_STR_KEY)
diff --git a/Lib/os.py b/Lib/os.py
index b794159f86..449cf932b6 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -36,7 +36,7 @@
__all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",
"defpath", "name", "path", "devnull", "SEEK_SET", "SEEK_CUR",
"SEEK_END", "fsencode", "fsdecode", "get_exec_path", "fdopen",
- "popen", "extsep"]
+ "popen", "extsep", "allows_subprocesses"]
def _exists(name):
return name in globals()
@@ -830,6 +830,13 @@
fsencode, fsdecode = _fscodec()
del _fscodec
+
+if sys.platform in ('iOS', 'tvos', 'watchos'):
+ allows_subprocesses = False
+else:
+ allows_subprocesses = True
+
+
# Supply spawn*() (probably only for Unix)
if _exists("fork") and not _exists("spawnv") and _exists("execv"):
diff --git a/Lib/platform.py b/Lib/platform.py
index 6258827d0e..af32c6c70c 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -613,7 +613,7 @@
default in case the command should fail.
"""
- if sys.platform in ('dos', 'win32', 'win16'):
+ if sys.platform in ('dos', 'win32', 'win16', 'ios', 'tvos', 'watchos'):
# XXX Others too ?
return default
diff --git a/Lib/site.py b/Lib/site.py
index 9e617afb00..41305298d3 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -271,6 +271,9 @@
if sys.platform == 'darwin' and sys._framework:
return f'{userbase}/lib/python/site-packages'
+ elif sys.platform in ('ios', 'tvos', 'watchos'):
+ from sysconfig import get_path
+ return get_path('purelib', sys.platform)
return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages'
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 0311e3a1f8..ca01e9aa16 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -762,6 +762,9 @@
pass_fds=(), *, user=None, group=None, extra_groups=None,
encoding=None, errors=None, text=None, umask=-1):
"""Create new Popen instance."""
+ if not os.allows_subprocesses:
+ raise RuntimeError("Subprocesses are not supported on this platform.")
+
_cleanup()
# Held while anything is calling waitpid before returncode has been
# updated to prevent clobbering returncode if wait() or poll() are
@@ -1834,7 +1837,7 @@
else:
self.returncode = waitstatus_to_exitcode(sts)
- def _internal_poll(self, _deadstate=None, _waitpid=os.waitpid,
+ def _internal_poll(self, _deadstate=None, _waitpid=None,
_WNOHANG=os.WNOHANG, _ECHILD=errno.ECHILD):
"""Check if child process has terminated. Returns returncode
attribute.
@@ -1843,6 +1846,8 @@
outside of the local scope (nor can any methods it calls).
"""
+ if _waitpid is None:
+ _waitpid = os.waitpid
if self.returncode is None:
if not self._waitpid_lock.acquire(False):
# Something else is busy calling waitpid. Don't allow two
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index e3f79bfde5..2850eaeb5e 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -84,6 +84,33 @@
'scripts': '{userbase}/bin',
'data': '{userbase}',
},
+ 'ios': {
+ 'stdlib': '{installed_base}/lib/python%s' % sys.version[:3],
+ 'platstdlib': '{installed_base}/lib/python%s' % sys.version[:3],
+ 'purelib': '{installed_base}/lib/python%s/site-packages' % sys.version[:3],
+ 'platlib': '{installed_base}/lib/python%s/site-packages' % sys.version[:3],
+ 'include': '{installed_base}/include',
+ 'scripts': '{installed_base}/bin',
+ 'data': '{installed_base}/Resources',
+ },
+ 'tvos': {
+ 'stdlib': '{installed_base}/lib/python%s' % sys.version[:3],
+ 'platstdlib': '{installed_base}/lib/python%s' % sys.version[:3],
+ 'purelib': '{installed_base}/lib/python%s/site-packages' % sys.version[:3],
+ 'platlib': '{installed_base}/lib/python%s/site-packages' % sys.version[:3],
+ 'include': '{installed_base}/include',
+ 'scripts': '{installed_base}/bin',
+ 'data': '{installed_base}/Resources',
+ },
+ 'watchos': {
+ 'stdlib': '{installed_base}/lib/python%s' % sys.version[:3],
+ 'platstdlib': '{installed_base}/lib/python%s' % sys.version[:3],
+ 'purelib': '{installed_base}/lib/python%s/site-packages' % sys.version[:3],
+ 'platlib': '{installed_base}/lib/python%s/site-packages' % sys.version[:3],
+ 'include': '{installed_base}/include',
+ 'scripts': '{installed_base}/bin',
+ 'data': '{installed_base}/Resources',
+ },
}
_SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
@@ -185,6 +212,8 @@
if os.name == 'posix':
# the default scheme for posix is posix_prefix
return 'posix_prefix'
+ elif sys.platform in ('ios', 'tvos', 'watchos'):
+ return sys.platform
return os.name
@@ -205,6 +234,11 @@
if sys.platform == "darwin" and sys._framework:
return joinuser("~", "Library", sys._framework,
"%d.%d" % sys.version_info[:2])
+ elif sys.platform in ('ios', 'tvos', 'watchos'):
+ if env_base:
+ return env_base
+ else:
+ return _BASE_PREFIX
return joinuser("~", ".local")
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index aee3737ffc..b7060d9d1a 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -782,8 +782,8 @@
# TESTFN_UNICODE is a non-ascii filename
TESTFN_UNICODE = TESTFN_ASCII + "-\xe0\xf2\u0258\u0141\u011f"
-if sys.platform == 'darwin':
- # In Mac OS X's VFS API file names are, by definition, canonically
+if sys.platform in ('darwin', 'ios', 'tvos', 'watchos'):
+ # In iOS and Mac OS X, VFS API file names are, by definition, canonically
# decomposed Unicode, encoded using UTF-8. See QA1173:
# http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
import unicodedata
@@ -809,8 +809,8 @@
'Unicode filename tests may not be effective'
% (TESTFN_UNENCODABLE, TESTFN_ENCODING))
TESTFN_UNENCODABLE = None
-# Mac OS X denies unencodable filenames (invalid utf-8)
-elif sys.platform != 'darwin':
+# Mac OS X and iOS deny unencodable filenames (invalid utf-8)
+elif sys.platform not in ('darwin', 'ios', 'tvos', 'watchos'):
try:
# ascii and utf-8 cannot encode the byte 0xff
b'\xff'.decode(TESTFN_ENCODING)
diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py
index 37e576d4a7..1d7176bf13 100644
--- a/Lib/test/support/script_helper.py
+++ b/Lib/test/support/script_helper.py
@@ -8,6 +8,7 @@
import os.path
import subprocess
import py_compile
+import unittest
import zipfile
from importlib.util import source_from_cache
@@ -17,6 +18,8 @@
# Cached result of the expensive test performed in the function below.
__cached_interp_requires_environment = None
+
+@unittest.skipUnless(os.allows_subprocesses, 'Test requires support for subprocesses.')
def interpreter_requires_environment():
"""
Returns True if our sys.executable interpreter requires environment
@@ -136,6 +139,7 @@
rc = proc.returncode
return _PythonRunResult(rc, out, err), cmd_line
+@unittest.skipUnless(os.allows_subprocesses, 'Test requires support for subprocesses.')
def _assert_python(expected_success, /, *args, **env_vars):
res, cmd_line = run_python_until_end(*args, **env_vars)
if (res.rc and expected_success) or (not res.rc and not expected_success):
@@ -165,6 +169,8 @@
"""
return _assert_python(False, *args, **env_vars)
+
+@unittest.skipUnless(os.allows_subprocesses, 'Test requires support for subprocesses.')
def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
"""Run a Python subprocess with the given arguments.
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index fa6c49d89d..1e3db27552 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -516,6 +516,8 @@
self._basetest_create_connection(conn_fut)
@socket_helper.skip_unless_bind_unix_socket
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_unix_connection(self):
# Issue #20682: On Mac OS X Tiger, getsockname() returns a
# zero-length address for UNIX socket.
@@ -608,6 +610,8 @@
self.assertEqual(cm.exception.reason, 'CERTIFICATE_VERIFY_FAILED')
@unittest.skipIf(ssl is None, 'No ssl module')
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_ssl_connection(self):
with test_utils.run_test_server(use_ssl=True) as httpd:
create_connection = functools.partial(
@@ -619,6 +623,8 @@
@socket_helper.skip_unless_bind_unix_socket
@unittest.skipIf(ssl is None, 'No ssl module')
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_ssl_unix_connection(self):
# Issue #20682: On Mac OS X Tiger, getsockname() returns a
# zero-length address for UNIX socket.
@@ -842,6 +848,8 @@
return server, path
@socket_helper.skip_unless_bind_unix_socket
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_unix_server(self):
proto = MyProto(loop=self.loop)
server, path = self._make_unix_server(lambda: proto)
@@ -870,6 +878,8 @@
server.close()
@unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets')
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_unix_server_path_socket_error(self):
proto = MyProto(loop=self.loop)
sock = socket.socket()
@@ -935,6 +945,8 @@
@socket_helper.skip_unless_bind_unix_socket
@unittest.skipIf(ssl is None, 'No ssl module')
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_unix_server_ssl(self):
proto = MyProto(loop=self.loop)
server, path = self._make_ssl_unix_server(
@@ -965,6 +977,8 @@
server.close()
@unittest.skipIf(ssl is None, 'No ssl module')
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_server_ssl_verify_failed(self):
proto = MyProto(loop=self.loop)
server, host, port = self._make_ssl_server(
@@ -995,6 +1009,8 @@
@socket_helper.skip_unless_bind_unix_socket
@unittest.skipIf(ssl is None, 'No ssl module')
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_unix_server_ssl_verify_failed(self):
proto = MyProto(loop=self.loop)
server, path = self._make_ssl_unix_server(
@@ -1055,6 +1071,8 @@
@socket_helper.skip_unless_bind_unix_socket
@unittest.skipIf(ssl is None, 'No ssl module')
+ @unittest.skipIf(sys.platform in ('ios', 'tvos', 'watchos'),
+ "%s doesn't fully support UNIX sockets." % sys.platform)
def test_create_unix_server_ssl_verified(self):
proto = MyProto(loop=self.loop)
server, path = self._make_ssl_unix_server(
@@ -1714,6 +1732,7 @@
next(it)
+@unittest.skipUnless(os.allows_subprocesses, 'Test requires support for subprocesses.')
class SubprocessTestsMixin: