Skip to content

Commit 845676d

Browse files
Merge branch 'main' into typevar-subst2
2 parents e4345da + 32bf359 commit 845676d

12 files changed

Lines changed: 61 additions & 15 deletions

File tree

Doc/whatsnew/3.11.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ Build Changes
645645
* Building Python now requires a C11 compiler without optional C11 features.
646646
(Contributed by Victor Stinner in :issue:`46656`.)
647647

648+
* Building Python now requires support of IEEE 754 floating point numbers.
649+
(Contributed by Victor Stinner in :issue:`46917`.)
650+
648651
* CPython can now be built with the ThinLTO option via ``--with-lto=thin``.
649652
(Contributed by Dong-hee Na and Brett Holman in :issue:`44340`.)
650653

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def requires_fork():
517517
has_subprocess_support = not is_emscripten and not is_wasi
518518

519519
def requires_subprocess():
520-
"""Used for subprocess, os.spawn calls"""
520+
"""Used for subprocess, os.spawn calls, fd inheritance"""
521521
return unittest.skipUnless(has_subprocess_support, "requires subprocess support")
522522

523523

Lib/test/test_os.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,7 @@ def test_write(self):
21922192
def test_writev(self):
21932193
self.check(os.writev, [b'abc'])
21942194

2195+
@support.requires_subprocess()
21952196
def test_inheritable(self):
21962197
self.check(os.get_inheritable)
21972198
self.check(os.set_inheritable, True)
@@ -3866,6 +3867,8 @@ def test_cpu_count(self):
38663867
self.skipTest("Could not determine the number of CPUs")
38673868

38683869

3870+
# FD inheritance check is only useful for systems with process support.
3871+
@support.requires_subprocess()
38693872
class FDInheritanceTests(unittest.TestCase):
38703873
def test_get_set_inheritable(self):
38713874
fd = os.open(__file__, os.O_RDONLY)

Lib/test/test_pathlib.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from unittest import mock
1414

1515
from test.support import import_helper
16+
from test.support import is_emscripten
1617
from test.support import os_helper
1718
from test.support.os_helper import TESTFN, FakePath
1819

@@ -2158,6 +2159,7 @@ def test_mkdir_exist_ok_with_parent(self):
21582159
self.assertTrue(p.exists())
21592160
self.assertEqual(p.stat().st_ctime, st_ctime_first)
21602161

2162+
@unittest.skipIf(is_emscripten, "FS root cannot be modified on Emscripten.")
21612163
def test_mkdir_exist_ok_root(self):
21622164
# Issue #25803: A drive root could raise PermissionError on Windows.
21632165
self.cls('/').resolve().mkdir(exist_ok=True)
@@ -2342,6 +2344,9 @@ def test_is_socket_false(self):
23422344
self.assertIs((P / 'fileA\x00').is_socket(), False)
23432345

23442346
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
2347+
@unittest.skipIf(
2348+
is_emscripten, "Unix sockets are not implemented on Emscripten."
2349+
)
23452350
def test_is_socket_true(self):
23462351
P = self.cls(BASE, 'mysock')
23472352
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -2497,6 +2502,9 @@ def _check_symlink_loop(self, *args, strict=True):
24972502
with self.assertRaises(RuntimeError):
24982503
print(path.resolve(strict))
24992504

2505+
@unittest.skipIf(
2506+
is_emscripten, "umask is not implemented on Emscripten."
2507+
)
25002508
def test_open_mode(self):
25012509
old_mask = os.umask(0)
25022510
self.addCleanup(os.umask, old_mask)
@@ -2520,6 +2528,9 @@ def test_resolve_root(self):
25202528
finally:
25212529
os.chdir(current_directory)
25222530

2531+
@unittest.skipIf(
2532+
is_emscripten, "umask is not implemented on Emscripten."
2533+
)
25232534
def test_touch_mode(self):
25242535
old_mask = os.umask(0)
25252536
self.addCleanup(os.umask, old_mask)

Lib/test/test_posix.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
_DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(),
3131
os_helper.TESTFN + '-dummy-symlink')
3232

33-
requires_32b = unittest.skipUnless(sys.maxsize < 2**32,
34-
'test is only meaningful on 32-bit builds')
33+
requires_32b = unittest.skipUnless(
34+
# Emscripten has 32 bits pointers, but support 64 bits syscall args.
35+
sys.maxsize < 2**32 and not support.is_emscripten,
36+
'test is only meaningful on 32-bit builds'
37+
)
3538

3639
def _supports_sched():
3740
if not hasattr(posix, 'sched_getscheduler'):
@@ -578,6 +581,7 @@ def test_dup2(self):
578581

579582
@unittest.skipUnless(hasattr(os, 'O_CLOEXEC'), "needs os.O_CLOEXEC")
580583
@support.requires_linux_version(2, 6, 23)
584+
@support.requires_subprocess()
581585
def test_oscloexec(self):
582586
fd = os.open(os_helper.TESTFN, os.O_RDONLY|os.O_CLOEXEC)
583587
self.addCleanup(os.close, fd)
@@ -737,7 +741,11 @@ def check_stat(uid, gid):
737741
is_root = (uid in (0, 1))
738742
else:
739743
is_root = (uid == 0)
740-
if is_root:
744+
if support.is_emscripten:
745+
# Emscripten getuid() / geteuid() always return 0 (root), but
746+
# cannot chown uid/gid to random value.
747+
pass
748+
elif is_root:
741749
# Try an amusingly large uid/gid to make sure we handle
742750
# large unsigned values. (chown lets you use any
743751
# uid/gid you like, even if they aren't defined.)

Lib/test/test_tarfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ def test_stream_padding(self):
14981498

14991499
@unittest.skipUnless(sys.platform != "win32" and hasattr(os, "umask"),
15001500
"Missing umask implementation")
1501+
@unittest.skipIf(support.is_emscripten, "Emscripten's umask is a stub.")
15011502
def test_file_mode(self):
15021503
# Test for issue #8464: Create files with correct
15031504
# permissions.

Lib/test/test_typing.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5813,6 +5813,27 @@ def test_paramspec_in_nested_generics(self):
58135813
self.assertEqual(G2[[int, str], float], list[C])
58145814
self.assertEqual(G3[[int, str], float], list[C] | int)
58155815

5816+
def test_paramspec_gets_copied(self):
5817+
# bpo-46581
5818+
P = ParamSpec('P')
5819+
P2 = ParamSpec('P2')
5820+
C1 = Callable[P, int]
5821+
self.assertEqual(C1.__parameters__, (P,))
5822+
self.assertEqual(C1[P2].__parameters__, (P2,))
5823+
self.assertEqual(C1[str].__parameters__, ())
5824+
self.assertEqual(C1[str, T].__parameters__, (T,))
5825+
self.assertEqual(C1[Concatenate[str, P2]].__parameters__, (P2,))
5826+
self.assertEqual(C1[Concatenate[T, P2]].__parameters__, (T, P2))
5827+
self.assertEqual(C1[...].__parameters__, ())
5828+
5829+
C2 = Callable[Concatenate[str, P], int]
5830+
self.assertEqual(C2.__parameters__, (P,))
5831+
self.assertEqual(C2[P2].__parameters__, (P2,))
5832+
self.assertEqual(C2[str].__parameters__, ())
5833+
self.assertEqual(C2[str, T].__parameters__, (T,))
5834+
self.assertEqual(C2[Concatenate[str, P2]].__parameters__, (P2,))
5835+
self.assertEqual(C2[Concatenate[T, P2]].__parameters__, (T, P2))
5836+
58165837

58175838
class ConcatenateTests(BaseTestCase):
58185839
def test_basics(self):

Lib/typing.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,8 @@ def Concatenate(self, parameters):
673673
"ParamSpec variable.")
674674
msg = "Concatenate[arg, ...]: each arg must be a type."
675675
parameters = (*(_type_check(p, msg) for p in parameters[:-1]), parameters[-1])
676-
return _ConcatenateGenericAlias(self, parameters)
676+
return _ConcatenateGenericAlias(self, parameters,
677+
_paramspec_tvars=True)
677678

678679

679680
@_SpecialForm
@@ -1350,7 +1351,8 @@ def _determine_new_args(self, args):
13501351
return tuple(new_args)
13511352

13521353
def copy_with(self, args):
1353-
return self.__class__(self.__origin__, args, name=self._name, inst=self._inst)
1354+
return self.__class__(self.__origin__, args, name=self._name, inst=self._inst,
1355+
_paramspec_tvars=self._paramspec_tvars)
13541356

13551357
def __repr__(self):
13561358
if self._name:
@@ -1558,10 +1560,6 @@ def __hash__(self):
15581560

15591561

15601562
class _ConcatenateGenericAlias(_GenericAlias, _root=True):
1561-
def __init__(self, *args, **kwargs):
1562-
super().__init__(*args, **kwargs,
1563-
_paramspec_tvars=True)
1564-
15651563
def copy_with(self, params):
15661564
if isinstance(params[-1], (list, tuple)):
15671565
return (*params[:-1], *params[-1])

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ Paul Boddie
190190
Matthew Boedicker
191191
Robin Boerdijk
192192
Andra Bogildea
193+
Matt Bogosian
193194
Nikolay Bogoychev
194195
David Bolen
195196
Wouter Bolsterlee
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Building Python now requires support of IEEE 754 floating point numbers.
2+
Patch by Victor Stinner.

0 commit comments

Comments
 (0)