Skip to content

Commit 0c4ff5a

Browse files
committed
Merge branch 'main' into pr/92078
2 parents 4ca6185 + 79ba564 commit 0c4ff5a

22 files changed

+9506
-337
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ jobs:
264264
fail-fast: false
265265
matrix:
266266
os: [ubuntu-24.04]
267-
openssl_ver: [3.0.15, 3.1.7, 3.2.3, 3.3.2, 3.4.0]
267+
openssl_ver: [3.0.16, 3.1.8, 3.2.4, 3.3.3, 3.4.1]
268268
# See Tools/ssl/make_ssl_data.py for notes on adding a new version
269269
env:
270270
OPENSSL_VER: ${{ matrix.openssl_ver }}
@@ -331,7 +331,7 @@ jobs:
331331
needs: build-context
332332
if: needs.build-context.outputs.run-tests == 'true'
333333
env:
334-
OPENSSL_VER: 3.0.15
334+
OPENSSL_VER: 3.0.16
335335
PYTHONSTRICTEXTENSIONBUILD: 1
336336
steps:
337337
- uses: actions/checkout@v4
@@ -450,7 +450,7 @@ jobs:
450450
matrix:
451451
os: [ubuntu-24.04]
452452
env:
453-
OPENSSL_VER: 3.0.15
453+
OPENSSL_VER: 3.0.16
454454
PYTHONSTRICTEXTENSIONBUILD: 1
455455
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
456456
steps:

Doc/c-api/arg.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ Building values
669669
``L`` (:class:`int`) [long long]
670670
Convert a C :c:expr:`long long` to a Python integer object.
671671
672+
.. _capi-py-buildvalue-format-K:
673+
672674
``K`` (:class:`int`) [unsigned long long]
673675
Convert a C :c:expr:`unsigned long long` to a Python integer object.
674676

Doc/using/configure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Features and minimum versions required to build CPython:
2222

2323
* Support for threads.
2424

25-
* OpenSSL 1.1.1 is the minimum version and OpenSSL 3.0.9 is the recommended
25+
* OpenSSL 1.1.1 is the minimum version and OpenSSL 3.0.16 is the recommended
2626
minimum version for the :mod:`ssl` and :mod:`hashlib` extension modules.
2727

2828
* SQLite 3.15.2 for the :mod:`sqlite3` extension module.

Lib/enum.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,16 @@ def __contains__(cls, value):
731731
"""
732732
if isinstance(value, cls):
733733
return True
734-
try:
735-
cls(value)
736-
return True
737-
except ValueError:
738-
return (
739-
value in cls._unhashable_values_ # both structures are lists
740-
or value in cls._hashable_values_
741-
)
734+
if issubclass(cls, Flag):
735+
try:
736+
result = cls._missing_(value)
737+
return isinstance(result, cls)
738+
except ValueError:
739+
pass
740+
return (
741+
value in cls._unhashable_values_ # both structures are lists
742+
or value in cls._hashable_values_
743+
)
742744

743745
def __delattr__(cls, attr):
744746
# nicer error message when someone tries to delete an attribute

Lib/statistics.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
from decimal import Decimal
139139
from itertools import count, groupby, repeat
140140
from bisect import bisect_left, bisect_right
141-
from math import hypot, sqrt, fabs, exp, erf, tau, log, fsum, sumprod
141+
from math import hypot, sqrt, fabs, exp, erfc, tau, log, fsum, sumprod
142142
from math import isfinite, isinf, pi, cos, sin, tan, cosh, asin, atan, acos
143143
from functools import reduce
144144
from operator import itemgetter
@@ -811,8 +811,9 @@ def deco(builder):
811811
def normal_kernel():
812812
sqrt2pi = sqrt(2 * pi)
813813
sqrt2 = sqrt(2)
814+
neg_sqrt2 = -sqrt2
814815
pdf = lambda t: exp(-1/2 * t * t) / sqrt2pi
815-
cdf = lambda t: 1/2 * (1.0 + erf(t / sqrt2))
816+
cdf = lambda t: 1/2 * erfc(t / neg_sqrt2)
816817
invcdf = lambda t: _normal_dist_inv_cdf(t, 0.0, 1.0)
817818
support = None
818819
return pdf, cdf, invcdf, support
@@ -1257,7 +1258,7 @@ def cdf(self, x):
12571258
"Cumulative distribution function. P(X <= x)"
12581259
if not self._sigma:
12591260
raise StatisticsError('cdf() not defined when sigma is zero')
1260-
return 0.5 * (1.0 + erf((x - self._mu) / (self._sigma * _SQRT2)))
1261+
return 0.5 * erfc((self._mu - x) / (self._sigma * _SQRT2))
12611262

12621263
def inv_cdf(self, p):
12631264
"""Inverse cumulative distribution function. x : P(X <= x) = p
@@ -1311,7 +1312,7 @@ def overlap(self, other):
13111312
dv = Y_var - X_var
13121313
dm = fabs(Y._mu - X._mu)
13131314
if not dv:
1314-
return 1.0 - erf(dm / (2.0 * X._sigma * _SQRT2))
1315+
return erfc(dm / (2.0 * X._sigma * _SQRT2))
13151316
a = X._mu * Y_var - Y._mu * X_var
13161317
b = X._sigma * Y._sigma * sqrt(dm * dm + dv * log(Y_var / X_var))
13171318
x1 = (a + b) / dv

Lib/test/clinic.test.c

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -4238,44 +4238,6 @@ static PyObject *
42384238
test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args)
42394239
/*[clinic end generated code: output=0c11c475e240869e input=2c49a482f68545c0]*/
42404240

4241-
PyDoc_STRVAR(test_vararg_and_posonly__doc__,
4242-
"test_vararg_and_posonly($module, a, /, *args)\n"
4243-
"--\n"
4244-
"\n");
4245-
4246-
#define TEST_VARARG_AND_POSONLY_METHODDEF \
4247-
{"test_vararg_and_posonly", _PyCFunction_CAST(test_vararg_and_posonly), METH_FASTCALL, test_vararg_and_posonly__doc__},
4248-
4249-
static PyObject *
4250-
test_vararg_and_posonly_impl(PyObject *module, PyObject *a, Py_ssize_t nargs,
4251-
PyObject *const *args);
4252-
4253-
static PyObject *
4254-
test_vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
4255-
{
4256-
PyObject *return_value = NULL;
4257-
Py_ssize_t nvararg = nargs - 1;
4258-
PyObject *a;
4259-
PyObject *const *__clinic_args = NULL;
4260-
4261-
if (!_PyArg_CheckPositional("test_vararg_and_posonly", nargs, 1, PY_SSIZE_T_MAX)) {
4262-
goto exit;
4263-
}
4264-
a = args[0];
4265-
__clinic_args = _PyTuple_FromArray(args + 1, nargs - 1);
4266-
if (__clinic_args == NULL) {
4267-
goto exit;
4268-
}
4269-
return_value = test_vararg_and_posonly_impl(module, a, nvararg, __clinic_args);
4270-
4271-
exit:
4272-
/* Cleanup for args */
4273-
Py_XDECREF(__clinic_args);
4274-
4275-
return return_value;
4276-
}
4277-
4278-
42794241
/*[clinic input]
42804242
test_vararg
42814243
@@ -5099,39 +5061,6 @@ static int
50995061
Test___init___impl(TestObj *self, PyObject *args)
51005062
/*[clinic end generated code: output=f172425cec373cd6 input=4b8388c4e6baab6f]*/
51015063

5102-
PyDoc_STRVAR(Test___init____doc__,
5103-
"Test(*args)\n"
5104-
"--\n"
5105-
"\n"
5106-
"Varargs init method. For example, nargs is translated to PyTuple_GET_SIZE.");
5107-
5108-
static int
5109-
Test___init___impl(TestObj *self, Py_ssize_t nargs, PyObject *const *args);
5110-
5111-
static int
5112-
Test___init__(PyObject *self, PyObject *args, PyObject *kwargs)
5113-
{
5114-
int return_value = -1;
5115-
PyTypeObject *base_tp = TestType;
5116-
PyObject *const *__clinic_args = NULL;
5117-
5118-
if ((Py_IS_TYPE(self, base_tp) ||
5119-
Py_TYPE(self)->tp_new == base_tp->tp_new) &&
5120-
!_PyArg_NoKeywords("Test", kwargs)) {
5121-
goto exit;
5122-
}
5123-
__clinic_args = Py_NewRef(args);
5124-
return_value = Test___init___impl((TestObj *)self, nvararg, __clinic_args);
5125-
5126-
exit:
5127-
/* Cleanup for args */
5128-
Py_XDECREF(__clinic_args);
5129-
5130-
return return_value;
5131-
}
5132-
5133-
5134-
51355064
/*[clinic input]
51365065
@classmethod
51375066
Test.__new__
@@ -5174,37 +5103,6 @@ static PyObject *
51745103
Test_impl(PyTypeObject *type, PyObject *args)
51755104
/*[clinic end generated code: output=ee1e8892a67abd4a input=a8259521129cad20]*/
51765105

5177-
PyDoc_STRVAR(Test__doc__,
5178-
"Test(*args)\n"
5179-
"--\n"
5180-
"\n"
5181-
"Varargs new method. For example, nargs is translated to PyTuple_GET_SIZE.");
5182-
5183-
static PyObject *
5184-
Test_impl(PyTypeObject *type, Py_ssize_t nargs, PyObject *const *args);
5185-
5186-
static PyObject *
5187-
Test(PyTypeObject *type, PyObject *args, PyObject *kwargs)
5188-
{
5189-
PyObject *return_value = NULL;
5190-
PyTypeObject *base_tp = TestType;
5191-
PyObject *const *__clinic_args = NULL;
5192-
5193-
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
5194-
!_PyArg_NoKeywords("Test", kwargs)) {
5195-
goto exit;
5196-
}
5197-
__clinic_args = Py_NewRef(args);
5198-
return_value = Test_impl(type, nvararg, __clinic_args);
5199-
5200-
exit:
5201-
/* Cleanup for args */
5202-
Py_XDECREF(__clinic_args);
5203-
5204-
return return_value;
5205-
}
5206-
5207-
52085106

52095107
/*[clinic input]
52105108
Test.__init__
@@ -6080,37 +5978,6 @@ static PyObject *
60805978
test_critical_section_object_impl(PyObject *module, PyObject *a)
60815979
/*[clinic end generated code: output=ec06df92232b0fb5 input=6f67f91b523c875f]*/
60825980

6083-
PyDoc_STRVAR(test_critical_section_object__doc__,
6084-
"test_critical_section_object($module, a, /)\n"
6085-
"--\n"
6086-
"\n"
6087-
"test_critical_section_object");
6088-
6089-
#define TEST_CRITICAL_SECTION_OBJECT_METHODDEF \
6090-
{"test_critical_section_object", (PyCFunction)test_critical_section_object, METH_O, test_critical_section_object__doc__},
6091-
6092-
static PyObject *
6093-
test_critical_section_object_impl(PyObject *module, PyObject *a);
6094-
6095-
static PyObject *
6096-
test_critical_section_object(PyObject *module, PyObject *arg)
6097-
{
6098-
PyObject *return_value = NULL;
6099-
PyObject *a;
6100-
6101-
if (!PyUnicode_Check(arg)) {
6102-
_PyArg_BadArgument("test_critical_section_object", "argument", "str", arg);
6103-
goto exit;
6104-
}
6105-
a = arg;
6106-
Py_BEGIN_CRITICAL_SECTION(a);
6107-
return_value = test_critical_section_object_impl(module, a);
6108-
Py_END_CRITICAL_SECTION();
6109-
6110-
exit:
6111-
return return_value;
6112-
}
6113-
61145981
/*[clinic input]
61155982
@critical_section a b
61165983
test_critical_section_object2
@@ -6165,44 +6032,3 @@ static PyObject *
61656032
test_critical_section_object2_impl(PyObject *module, PyObject *a,
61666033
PyObject *b)
61676034
/*[clinic end generated code: output=d73a1657c18df17a input=638824e41419a466]*/
6168-
6169-
PyDoc_STRVAR(test_critical_section_object2__doc__,
6170-
"test_critical_section_object2($module, a, b, /)\n"
6171-
"--\n"
6172-
"\n"
6173-
"test_critical_section_object2");
6174-
6175-
#define TEST_CRITICAL_SECTION_OBJECT2_METHODDEF \
6176-
{"test_critical_section_object2", _PyCFunction_CAST(test_critical_section_object2), METH_FASTCALL, test_critical_section_object2__doc__},
6177-
6178-
static PyObject *
6179-
test_critical_section_object2_impl(PyObject *module, PyObject *a,
6180-
PyObject *b);
6181-
6182-
static PyObject *
6183-
test_critical_section_object2(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
6184-
{
6185-
PyObject *return_value = NULL;
6186-
PyObject *a;
6187-
PyObject *b;
6188-
6189-
if (!_PyArg_CheckPositional("test_critical_section_object2", nargs, 2, 2)) {
6190-
goto exit;
6191-
}
6192-
if (!PyUnicode_Check(args[0])) {
6193-
_PyArg_BadArgument("test_critical_section_object2", "argument 1", "str", args[0]);
6194-
goto exit;
6195-
}
6196-
a = args[0];
6197-
if (!PyUnicode_Check(args[1])) {
6198-
_PyArg_BadArgument("test_critical_section_object2", "argument 2", "str", args[1]);
6199-
goto exit;
6200-
}
6201-
b = args[1];
6202-
Py_BEGIN_CRITICAL_SECTION2(a, b);
6203-
return_value = test_critical_section_object2_impl(module, a, b);
6204-
Py_END_CRITICAL_SECTION2();
6205-
6206-
exit:
6207-
return return_value;
6208-
}

Lib/test/support/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,8 +1940,9 @@ def missing_compiler_executable(cmd_names=[]):
19401940
missing.
19411941
19421942
"""
1943-
from setuptools._distutils import ccompiler, sysconfig, spawn
1943+
from setuptools._distutils import ccompiler, sysconfig
19441944
from setuptools import errors
1945+
import shutil
19451946

19461947
compiler = ccompiler.new_compiler()
19471948
sysconfig.customize_compiler(compiler)
@@ -1960,7 +1961,7 @@ def missing_compiler_executable(cmd_names=[]):
19601961
"the '%s' executable is not configured" % name
19611962
elif not cmd:
19621963
continue
1963-
if spawn.find_executable(cmd[0]) is None:
1964+
if shutil.which(cmd[0]) is None:
19641965
return cmd[0]
19651966

19661967

Lib/test/test_cppext/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import platform
55
import shlex
6+
import sys
67
import sysconfig
78
from test import support
89

Lib/test/test_enum.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,17 @@ class IntFlag1(IntFlag):
15691569
self.assertIn(IntEnum1.X, IntFlag1)
15701570
self.assertIn(IntFlag1.X, IntEnum1)
15711571

1572+
def test_contains_does_not_call_missing(self):
1573+
class AnEnum(Enum):
1574+
UNKNOWN = None
1575+
LUCKY = 3
1576+
@classmethod
1577+
def _missing_(cls, *values):
1578+
return cls.UNKNOWN
1579+
self.assertTrue(None in AnEnum)
1580+
self.assertTrue(3 in AnEnum)
1581+
self.assertFalse(7 in AnEnum)
1582+
15721583
def test_inherited_data_type(self):
15731584
class HexInt(int):
15741585
__qualname__ = 'HexInt'

0 commit comments

Comments
 (0)