Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b68cda

Browse filesBrowse files
authored
Merge branch 'python:main' into fix-typevar-test
2 parents a3c54d5 + 1578de2 commit 3b68cda
Copy full SHA for 3b68cda
Expand file treeCollapse file tree

40 files changed

+298
-93
lines changed

‎Doc/Makefile

Copy file name to clipboardExpand all lines: Doc/Makefile
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PAPER =
1212
SOURCES =
1313
DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
1414
SPHINXERRORHANDLING = -W
15+
SERVE_PORT =
1516

1617
# Internal variables.
1718
PAPEROPT_a4 = -D latex_elements.papersize=a4paper
@@ -217,7 +218,7 @@ check:
217218
$(PYTHON) tools/rstlint.py ../Misc/NEWS.d/next/
218219

219220
serve:
220-
$(PYTHON) ../Tools/scripts/serve.py build/html
221+
$(PYTHON) ../Tools/scripts/serve.py build/html $(SERVE_PORT)
221222

222223
# Targets for daily automated doc build
223224
# By default, Sphinx only rebuilds pages where the page content has changed.

‎Doc/library/cgi.rst

Copy file name to clipboardExpand all lines: Doc/library/cgi.rst
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Support module for Common Gateway Interface (CGI) scripts.
2121
This module defines a number of utilities for use by CGI scripts written in
2222
Python.
2323

24+
The global variable ``maxlen`` can be set to an integer indicating the maximum
25+
size of a POST request. POST requests larger than this size will result in a
26+
:exc:`ValueError` being raised during parsing. The default value of this
27+
variable is ``0``, meaning the request size is unlimited.
28+
2429

2530
Introduction
2631
------------

‎Doc/library/re.rst

Copy file name to clipboardExpand all lines: Doc/library/re.rst
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ form.
637637
programs that use only a few regular expressions at a time needn't worry
638638
about compiling regular expressions.
639639

640+
.. class:: RegexFlag
641+
642+
An :class:`enum.IntFlag` class containing the regex options listed below.
643+
644+
.. versionadded:: 3.11 - added to ``__all__``
640645

641646
.. data:: A
642647
ASCII
@@ -710,6 +715,17 @@ form.
710715
string and immediately before the newline (if any) at the end of the string.
711716
Corresponds to the inline flag ``(?m)``.
712717

718+
.. data:: NOFLAG
719+
720+
Indicates no flag being applied, the value is ``0``. This flag may be used
721+
as a default value for a function keyword argument or as a base value that
722+
will be conditionally ORed with other flags. Example of use as a default
723+
value::
724+
725+
def myfunc(text, flag=re.NOFLAG):
726+
return re.match(text, flag)
727+
728+
.. versionadded:: 3.11
713729

714730
.. data:: S
715731
DOTALL

‎Doc/tutorial/floatingpoint.rst

Copy file name to clipboardExpand all lines: Doc/tutorial/floatingpoint.rst
+3-9Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@ Floating Point Arithmetic: Issues and Limitations
1212

1313

1414
Floating-point numbers are represented in computer hardware as base 2 (binary)
15-
fractions. For example, the decimal fraction ::
16-
17-
0.125
18-
19-
has value 1/10 + 2/100 + 5/1000, and in the same way the binary fraction ::
20-
21-
0.001
22-
23-
has value 0/2 + 0/4 + 1/8. These two fractions have identical values, the only
15+
fractions. For example, the **decimal** fraction ``0.125``
16+
has value 1/10 + 2/100 + 5/1000, and in the same way the **binary** fraction ``0.001``
17+
has value 0/2 + 0/4 + 1/8. These two fractions have identical values, the only
2418
real difference being that the first is written in base 10 fractional notation,
2519
and the second in base 2.
2620

‎Doc/whatsnew/3.11.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.11.rst
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,12 @@ Build Changes
604604
``isinf()``, ``isnan()``, ``round()``.
605605
(Contributed by Victor Stinner in :issue:`45440`.)
606606

607+
* Building Python now requires a C99 ``<math.h>`` header file providing
608+
a ``NAN`` constant, or the ``__builtin_nan()`` built-in function. If a
609+
platform does not support Not-a-Number (NaN), the ``Py_NO_NAN`` macro can be
610+
defined in the ``pyconfig.h`` file.
611+
(Contributed by Victor Stinner in :issue:`46640`.)
612+
607613
* Freelists for object structs can now be disabled. A new :program:`configure`
608614
option :option:`!--without-freelists` can be used to disable all freelists
609615
except empty tuple singleton.

‎Include/pymath.h

Copy file name to clipboardExpand all lines: Include/pymath.h
+10-21Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,18 @@
5151
#endif
5252

5353
/* Py_NAN
54-
* A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or
55-
* INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform
56-
* doesn't support NaNs.
54+
* A value that evaluates to a quiet Not-a-Number (NaN).
55+
* Define Py_NO_NAN in pyconfig.h if your platform doesn't support NaNs.
5756
*/
5857
#if !defined(Py_NAN) && !defined(Py_NO_NAN)
59-
# if !defined(__INTEL_COMPILER)
60-
# define Py_NAN (Py_HUGE_VAL * 0.)
61-
# else /* __INTEL_COMPILER */
62-
# if defined(ICC_NAN_STRICT)
63-
#pragma float_control(push)
64-
#pragma float_control(precise, on)
65-
#pragma float_control(except, on)
66-
Py_NO_INLINE static double __icc_nan()
67-
{
68-
return sqrt(-1.0);
69-
}
70-
#pragma float_control (pop)
71-
# define Py_NAN __icc_nan()
72-
# else /* ICC_NAN_RELAXED as default for Intel Compiler */
73-
static const union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f};
74-
# define Py_NAN (__nan_store.__icc_nan)
75-
# endif /* ICC_NAN_STRICT */
76-
# endif /* __INTEL_COMPILER */
58+
# if _Py__has_builtin(__builtin_nan)
59+
// Built-in implementation of the ISO C99 function nan(): quiet NaN.
60+
# define Py_NAN (__builtin_nan(""))
61+
#else
62+
// Use C99 NAN constant: quiet Not-A-Number.
63+
// NAN is a float, Py_NAN is a double: cast to double.
64+
# define Py_NAN ((double)NAN)
65+
# endif
7766
#endif
7867

7968
#endif /* Py_PYMATH_H */

‎Lib/cgi.py

Copy file name to clipboardExpand all lines: Lib/cgi.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
1414
This module defines a number of utilities for use by CGI scripts
1515
written in Python.
16+
17+
The global variable maxlen can be set to an integer indicating the maximum size
18+
of a POST request. POST requests larger than this size will result in a
19+
ValueError being raised during parsing. The default value of this variable is 0,
20+
meaning the request size is unlimited.
1621
"""
1722

1823
# History

‎Lib/re.py

Copy file name to clipboardExpand all lines: Lib/re.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,15 @@
137137
"findall", "finditer", "compile", "purge", "template", "escape",
138138
"error", "Pattern", "Match", "A", "I", "L", "M", "S", "X", "U",
139139
"ASCII", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE",
140-
"UNICODE",
140+
"UNICODE", "NOFLAG", "RegexFlag",
141141
]
142142

143143
__version__ = "2.2.1"
144144

145145
@enum.global_enum
146146
@enum._simple_enum(enum.IntFlag, boundary=enum.KEEP)
147147
class RegexFlag:
148+
NOFLAG = 0
148149
ASCII = A = sre_compile.SRE_FLAG_ASCII # assume ascii "locale"
149150
IGNORECASE = I = sre_compile.SRE_FLAG_IGNORECASE # ignore case
150151
LOCALE = L = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale

‎Lib/test/support/__init__.py

Copy file name to clipboardExpand all lines: Lib/test/support/__init__.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,8 @@ def reap_children():
12781278
# Need os.waitpid(-1, os.WNOHANG): Windows is not supported
12791279
if not (hasattr(os, 'waitpid') and hasattr(os, 'WNOHANG')):
12801280
return
1281+
elif not has_subprocess_support:
1282+
return
12811283

12821284
# Reap all our dead child processes so we don't leave zombies around.
12831285
# These hog resources and might be causing some of the buildbots to die.

‎Lib/test/support/os_helper.py

Copy file name to clipboardExpand all lines: Lib/test/support/os_helper.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def __fspath__(self):
502502
def fd_count():
503503
"""Count the number of open file descriptors.
504504
"""
505-
if sys.platform.startswith(('linux', 'freebsd')):
505+
if sys.platform.startswith(('linux', 'freebsd', 'emscripten')):
506506
try:
507507
names = os.listdir("/proc/self/fd")
508508
# Subtract one because listdir() internally opens a file

‎Lib/test/test_builtin.py

Copy file name to clipboardExpand all lines: Lib/test/test_builtin.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def test_compile_top_level_await_no_coro(self):
393393
msg=f"source={source} mode={mode}")
394394

395395

396+
@unittest.skipIf(support.is_emscripten, "socket.accept is broken")
396397
def test_compile_top_level_await(self):
397398
"""Test whether code some top level await can be compiled.
398399
@@ -1213,6 +1214,7 @@ def test_open_default_encoding(self):
12131214
os.environ.clear()
12141215
os.environ.update(old_environ)
12151216

1217+
@support.requires_subprocess()
12161218
def test_open_non_inheritable(self):
12171219
fileobj = open(__file__, encoding="utf-8")
12181220
with fileobj:

‎Lib/test/test_capi.py

Copy file name to clipboardExpand all lines: Lib/test/test_capi.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ def check_fatal_error(self, code, expected, not_expected=()):
611611
self.assertNotIn(name, modules)
612612
self.assertEqual(len(modules), total)
613613

614+
@support.requires_subprocess()
614615
def test_fatal_error(self):
615616
# By default, stdlib extension modules are ignored,
616617
# but not test modules.
@@ -880,6 +881,7 @@ class Test_testinternalcapi(unittest.TestCase):
880881
if name.startswith('test_'))
881882

882883

884+
@support.requires_subprocess()
883885
class PyMemDebugTests(unittest.TestCase):
884886
PYTHONMALLOC = 'debug'
885887
# '0x04c06e0' or '04C06E0'

‎Lib/test/test_faulthandler.py

Copy file name to clipboardExpand all lines: Lib/test/test_faulthandler.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
except ImportError:
2020
_testcapi = None
2121

22+
if not support.has_subprocess_support:
23+
raise unittest.SkipTest("test module requires subprocess")
24+
2225
TIMEOUT = 0.5
2326
MS_WINDOWS = (os.name == 'nt')
2427

‎Lib/test/test_fileio.py

Copy file name to clipboardExpand all lines: Lib/test/test_fileio.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from weakref import proxy
1010
from functools import wraps
1111

12-
from test.support import cpython_only, swap_attr, gc_collect
12+
from test.support import cpython_only, swap_attr, gc_collect, is_emscripten
1313
from test.support.os_helper import (TESTFN, TESTFN_UNICODE, make_bad_fd)
1414
from test.support.warnings_helper import check_warnings
1515
from collections import UserList
@@ -373,7 +373,7 @@ def testAbles(self):
373373
self.assertEqual(f.isatty(), False)
374374
f.close()
375375

376-
if sys.platform != "win32":
376+
if sys.platform != "win32" and not is_emscripten:
377377
try:
378378
f = self.FileIO("/dev/tty", "a")
379379
except OSError:

‎Lib/test/test_genericalias.py

Copy file name to clipboardExpand all lines: Lib/test/test_genericalias.py
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,20 @@
2424
from fileinput import FileInput
2525
from itertools import chain
2626
from http.cookies import Morsel
27-
from multiprocessing.managers import ValueProxy
28-
from multiprocessing.pool import ApplyResult
27+
try:
28+
from multiprocessing.managers import ValueProxy
29+
from multiprocessing.pool import ApplyResult
30+
from multiprocessing.queues import SimpleQueue as MPSimpleQueue
31+
except ImportError:
32+
# _multiprocessing module is optional
33+
ValueProxy = None
34+
ApplyResult = None
35+
MPSimpleQueue = None
2936
try:
3037
from multiprocessing.shared_memory import ShareableList
3138
except ImportError:
3239
# multiprocessing.shared_memory is not available on e.g. Android
3340
ShareableList = None
34-
from multiprocessing.queues import SimpleQueue as MPSimpleQueue
3541
from os import DirEntry
3642
from re import Pattern, Match
3743
from types import GenericAlias, MappingProxyType, AsyncGeneratorType
@@ -79,13 +85,14 @@ class BaseTest(unittest.TestCase):
7985
Queue, SimpleQueue,
8086
_AssertRaisesContext,
8187
SplitResult, ParseResult,
82-
ValueProxy, ApplyResult,
8388
WeakSet, ReferenceType, ref,
84-
ShareableList, MPSimpleQueue,
89+
ShareableList,
8590
Future, _WorkItem,
8691
Morsel]
8792
if ctypes is not None:
8893
generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
94+
if ValueProxy is not None:
95+
generic_types.extend((ValueProxy, ApplyResult, MPSimpleQueue))
8996

9097
def test_subscriptable(self):
9198
for t in self.generic_types:

‎Lib/test/test_getpass.py

Copy file name to clipboardExpand all lines: Lib/test/test_getpass.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def test_username_priorities_of_env_values(self, environ):
2828
getpass.getuser()
2929
except ImportError: # in case there's no pwd module
3030
pass
31+
except KeyError:
32+
# current user has no pwd entry
33+
pass
3134
self.assertEqual(
3235
environ.get.call_args_list,
3336
[mock.call(x) for x in ('LOGNAME', 'USER', 'LNAME', 'USERNAME')])

‎Lib/test/test_inspect.py

Copy file name to clipboardExpand all lines: Lib/test/test_inspect.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ def test_nested_class_definition_inside_function(self):
788788
self.assertSourceEqual(mod2.cls213, 218, 222)
789789
self.assertSourceEqual(mod2.cls213().func219(), 220, 221)
790790

791+
@unittest.skipIf(support.is_emscripten, "socket.accept is broken")
791792
def test_nested_class_definition_inside_async_function(self):
792793
import asyncio
793794
self.addCleanup(asyncio.set_event_loop_policy, None)

‎Lib/test/test_interpreters.py

Copy file name to clipboardExpand all lines: Lib/test/test_interpreters.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import unittest
66
import time
77

8-
import _xxsubinterpreters as _interpreters
8+
from test.support import import_helper
9+
_interpreters = import_helper.import_module('_xxsubinterpreters')
910
from test.support import interpreters
1011

1112

‎Lib/test/test_io.py

Copy file name to clipboardExpand all lines: Lib/test/test_io.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ def _default_chunk_size():
7676
with open(__file__, "r", encoding="latin-1") as f:
7777
return f._CHUNK_SIZE
7878

79+
requires_alarm = unittest.skipUnless(
80+
hasattr(signal, "alarm"), "test requires signal.alarm()"
81+
)
82+
7983

8084
class MockRawIOWithoutRead:
8185
"""A RawIO implementation without read(), so as to exercise the default
@@ -4435,12 +4439,15 @@ def _read():
44354439
if e.errno != errno.EBADF:
44364440
raise
44374441

4442+
@requires_alarm
44384443
def test_interrupted_write_unbuffered(self):
44394444
self.check_interrupted_write(b"xy", b"xy", mode="wb", buffering=0)
44404445

4446+
@requires_alarm
44414447
def test_interrupted_write_buffered(self):
44424448
self.check_interrupted_write(b"xy", b"xy", mode="wb")
44434449

4450+
@requires_alarm
44444451
def test_interrupted_write_text(self):
44454452
self.check_interrupted_write("xy", b"xy", mode="w", encoding="ascii")
44464453

@@ -4472,9 +4479,11 @@ def on_alarm(*args):
44724479
wio.close()
44734480
os.close(r)
44744481

4482+
@requires_alarm
44754483
def test_reentrant_write_buffered(self):
44764484
self.check_reentrant_write(b"xy", mode="wb")
44774485

4486+
@requires_alarm
44784487
def test_reentrant_write_text(self):
44794488
self.check_reentrant_write("xy", mode="w", encoding="ascii")
44804489

@@ -4502,10 +4511,12 @@ def alarm_handler(sig, frame):
45024511
os.close(w)
45034512
os.close(r)
45044513

4514+
@requires_alarm
45054515
def test_interrupted_read_retry_buffered(self):
45064516
self.check_interrupted_read_retry(lambda x: x.decode('latin1'),
45074517
mode="rb")
45084518

4519+
@requires_alarm
45094520
def test_interrupted_read_retry_text(self):
45104521
self.check_interrupted_read_retry(lambda x: x,
45114522
mode="r", encoding="latin1")
@@ -4578,9 +4589,11 @@ def alarm2(sig, frame):
45784589
if e.errno != errno.EBADF:
45794590
raise
45804591

4592+
@requires_alarm
45814593
def test_interrupted_write_retry_buffered(self):
45824594
self.check_interrupted_write_retry(b"x", mode="wb")
45834595

4596+
@requires_alarm
45844597
def test_interrupted_write_retry_text(self):
45854598
self.check_interrupted_write_retry("x", mode="w", encoding="latin1")
45864599

‎Lib/test/test_os.py

Copy file name to clipboardExpand all lines: Lib/test/test_os.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ def _empty_mapping(self):
992992
@unittest.skipUnless(unix_shell and os.path.exists(unix_shell),
993993
'requires a shell')
994994
@unittest.skipUnless(hasattr(os, 'popen'), "needs os.popen()")
995+
@support.requires_subprocess()
995996
def test_update2(self):
996997
os.environ.clear()
997998
os.environ.update(HELLO="World")
@@ -1002,6 +1003,7 @@ def test_update2(self):
10021003
@unittest.skipUnless(unix_shell and os.path.exists(unix_shell),
10031004
'requires a shell')
10041005
@unittest.skipUnless(hasattr(os, 'popen'), "needs os.popen()")
1006+
@support.requires_subprocess()
10051007
def test_os_popen_iter(self):
10061008
with os.popen("%s -c 'echo \"line1\nline2\nline3\"'"
10071009
% unix_shell) as popen:
@@ -1173,6 +1175,8 @@ def test_iter_error_when_changing_os_environ_values(self):
11731175
def _test_underlying_process_env(self, var, expected):
11741176
if not (unix_shell and os.path.exists(unix_shell)):
11751177
return
1178+
elif not support.has_subprocess_support:
1179+
return
11761180

11771181
with os.popen(f"{unix_shell} -c 'echo ${var}'") as popen:
11781182
value = popen.read().strip()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.