Skip to content

Commit 0cecc48

Browse files
Merge branch '3.13' into backport-10bec7c-3.13
2 parents 9d8a3b7 + b693037 commit 0cecc48

16 files changed

+85
-126
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,10 @@ jobs:
154154
python-version: '3.x'
155155
- name: Runner image version
156156
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
157-
- name: Restore config.cache
158-
uses: actions/cache@v4
159-
with:
160-
path: config.cache
161-
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
162-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}-${{ env.pythonLocation }}
163157
- name: Install dependencies
164158
run: sudo ./.github/workflows/posix-deps-apt.sh
165159
- name: Add ccache to PATH
166160
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
167-
- name: Configure ccache action
168-
uses: hendrikmuhs/ccache-action@v1.2
169-
with:
170-
save: false
171161
- name: Configure CPython
172162
run: |
173163
# Build Python with the libpython dynamic library
@@ -268,7 +258,6 @@ jobs:
268258
free-threading: true
269259
uses: ./.github/workflows/reusable-macos.yml
270260
with:
271-
config_hash: ${{ needs.build-context.outputs.config-hash }}
272261
free-threading: ${{ matrix.free-threading }}
273262
os: ${{ matrix.os }}
274263

@@ -286,7 +275,6 @@ jobs:
286275
- true
287276
uses: ./.github/workflows/reusable-ubuntu.yml
288277
with:
289-
config_hash: ${{ needs.build-context.outputs.config-hash }}
290278
free-threading: ${{ matrix.free-threading }}
291279

292280
build-ubuntu-ssltests:
@@ -314,11 +302,6 @@ jobs:
314302
persist-credentials: false
315303
- name: Runner image version
316304
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
317-
- name: Restore config.cache
318-
uses: actions/cache@v4
319-
with:
320-
path: config.cache
321-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
322305
- name: Register gcc problem matcher
323306
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
324307
- name: Install dependencies
@@ -340,10 +323,6 @@ jobs:
340323
- name: Add ccache to PATH
341324
run: |
342325
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
343-
- name: Configure ccache action
344-
uses: hendrikmuhs/ccache-action@v1.2
345-
with:
346-
save: false
347326
- name: Configure CPython
348327
run: ./configure --config-cache --with-pydebug --with-openssl=$OPENSSL_DIR
349328
- name: Build CPython
@@ -380,8 +359,6 @@ jobs:
380359
needs: build-context
381360
if: needs.build-context.outputs.run-tests == 'true'
382361
uses: ./.github/workflows/reusable-wasi.yml
383-
with:
384-
config_hash: ${{ needs.build-context.outputs.config-hash }}
385362

386363
test-hypothesis:
387364
name: "Hypothesis tests on Ubuntu"
@@ -417,10 +394,6 @@ jobs:
417394
- name: Add ccache to PATH
418395
run: |
419396
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
420-
- name: Configure ccache action
421-
uses: hendrikmuhs/ccache-action@v1.2
422-
with:
423-
save: false
424397
- name: Setup directory envs for out-of-tree builds
425398
run: |
426399
echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV"
@@ -431,11 +404,6 @@ jobs:
431404
run: sudo mount --bind -o ro "$GITHUB_WORKSPACE" "$CPYTHON_RO_SRCDIR"
432405
- name: Runner image version
433406
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
434-
- name: Restore config.cache
435-
uses: actions/cache@v4
436-
with:
437-
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
438-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
439407
- name: Configure CPython out-of-tree
440408
working-directory: ${{ env.CPYTHON_BUILDDIR }}
441409
run: |
@@ -518,11 +486,6 @@ jobs:
518486
persist-credentials: false
519487
- name: Runner image version
520488
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
521-
- name: Restore config.cache
522-
uses: actions/cache@v4
523-
with:
524-
path: config.cache
525-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}
526489
- name: Register gcc problem matcher
527490
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
528491
- name: Install dependencies
@@ -548,11 +511,6 @@ jobs:
548511
- name: Add ccache to PATH
549512
run: |
550513
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
551-
- name: Configure ccache action
552-
uses: hendrikmuhs/ccache-action@v1.2
553-
with:
554-
save: ${{ github.event_name == 'push' }}
555-
max-size: "200M"
556514
- name: Configure CPython
557515
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc
558516
- name: Build CPython
@@ -580,7 +538,6 @@ jobs:
580538
uses: ./.github/workflows/reusable-san.yml
581539
with:
582540
sanitizer: ${{ matrix.sanitizer }}
583-
config_hash: ${{ needs.build-context.outputs.config-hash }}
584541
free-threading: ${{ matrix.free-threading }}
585542

586543
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/

.github/workflows/reusable-context.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ on: # yamllint disable-line rule:truthy
1717
# || 'falsy-branch'
1818
# }}
1919
#
20-
config-hash:
21-
description: Config hash value for use in cache keys
22-
value: ${{ jobs.compute-changes.outputs.config-hash }} # str
2320
run-docs:
2421
description: Whether to build the docs
2522
value: ${{ jobs.compute-changes.outputs.run-docs }} # bool
@@ -42,7 +39,6 @@ jobs:
4239
runs-on: ubuntu-latest
4340
timeout-minutes: 10
4441
outputs:
45-
config-hash: ${{ steps.config-hash.outputs.hash }}
4642
run-ci-fuzz: ${{ steps.changes.outputs.run-ci-fuzz }}
4743
run-docs: ${{ steps.changes.outputs.run-docs }}
4844
run-tests: ${{ steps.changes.outputs.run-tests }}
@@ -100,8 +96,3 @@ jobs:
10096
GITHUB_EVENT_NAME: ${{ github.event_name }}
10197
CCF_TARGET_REF: ${{ github.base_ref || github.event.repository.default_branch }}
10298
CCF_HEAD_REF: ${{ github.event.pull_request.head.sha || github.sha }}
103-
104-
- name: Compute hash for config cache key
105-
id: config-hash
106-
run: |
107-
echo "hash=${{ hashFiles('configure', 'configure.ac', '.github/workflows/build.yml') }}" >> "$GITHUB_OUTPUT"

.github/workflows/reusable-macos.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name: Reusable macOS
33
on:
44
workflow_call:
55
inputs:
6-
config_hash:
7-
required: true
8-
type: string
96
free-threading:
107
required: false
118
type: boolean
@@ -36,11 +33,6 @@ jobs:
3633
persist-credentials: false
3734
- name: Runner image version
3835
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
39-
- name: Restore config.cache
40-
uses: actions/cache@v4
41-
with:
42-
path: config.cache
43-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }}
4436
- name: Install Homebrew dependencies
4537
run: |
4638
brew install pkg-config openssl@3.0 xz gdbm tcl-tk@8

.github/workflows/reusable-san.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
sanitizer:
77
required: true
88
type: string
9-
config_hash:
10-
required: true
11-
type: string
129
free-threading:
1310
description: Whether to use free-threaded mode
1411
required: false
@@ -34,11 +31,6 @@ jobs:
3431
persist-credentials: false
3532
- name: Runner image version
3633
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
37-
- name: Restore config.cache
38-
uses: actions/cache@v4
39-
with:
40-
path: config.cache
41-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.sanitizer }}-${{ inputs.config_hash }}
4234
- name: Install dependencies
4335
run: |
4436
sudo ./.github/workflows/posix-deps-apt.sh
@@ -77,11 +69,6 @@ jobs:
7769
- name: Add ccache to PATH
7870
run: |
7971
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
80-
- name: Configure ccache action
81-
uses: hendrikmuhs/ccache-action@v1.2
82-
with:
83-
save: ${{ github.event_name == 'push' }}
84-
max-size: "200M"
8572
- name: Configure CPython
8673
run: >-
8774
./configure

.github/workflows/reusable-ubuntu.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name: Reusable Ubuntu
33
on:
44
workflow_call:
55
inputs:
6-
config_hash:
7-
required: true
8-
type: string
96
free-threading:
107
description: Whether to use free-threaded mode
118
required: false
@@ -53,11 +50,6 @@ jobs:
5350
- name: Add ccache to PATH
5451
run: |
5552
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
56-
- name: Configure ccache action
57-
uses: hendrikmuhs/ccache-action@v1.2
58-
with:
59-
save: ${{ github.event_name == 'push' }}
60-
max-size: "200M"
6153
- name: Setup directory envs for out-of-tree builds
6254
run: |
6355
echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV"
@@ -68,11 +60,6 @@ jobs:
6860
run: sudo mount --bind -o ro "$GITHUB_WORKSPACE" "$CPYTHON_RO_SRCDIR"
6961
- name: Runner image version
7062
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
71-
- name: Restore config.cache
72-
uses: actions/cache@v4
73-
with:
74-
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
75-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }}
7663
- name: Configure CPython out-of-tree
7764
working-directory: ${{ env.CPYTHON_BUILDDIR }}
7865
run: >-

.github/workflows/reusable-wasi.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: Reusable WASI
22

33
on:
44
workflow_call:
5-
inputs:
6-
config_hash:
7-
required: true
8-
type: string
95

106
env:
117
FORCE_COLOR: 1
@@ -42,11 +38,6 @@ jobs:
4238
mkdir "${WASI_SDK_PATH}" && \
4339
curl -s -S --location "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz" | \
4440
tar --strip-components 1 --directory "${WASI_SDK_PATH}" --extract --gunzip
45-
- name: "Configure ccache action"
46-
uses: hendrikmuhs/ccache-action@v1.2
47-
with:
48-
save: ${{ github.event_name == 'push' }}
49-
max-size: "200M"
5041
- name: "Add ccache to PATH"
5142
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
5243
- name: "Install Python"
@@ -55,24 +46,10 @@ jobs:
5546
python-version: '3.x'
5647
- name: "Runner image version"
5748
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
58-
- name: "Restore Python build config.cache"
59-
uses: actions/cache@v4
60-
with:
61-
path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
62-
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python.
63-
# Include the hash of `Tools/wasm/wasi.py` as it may change the environment variables.
64-
# (Make sure to keep the key in sync with the other config.cache step below.)
65-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
6649
- name: "Configure build Python"
6750
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
6851
- name: "Make build Python"
6952
run: python3 Tools/wasm/wasi.py make-build-python
70-
- name: "Restore host config.cache"
71-
uses: actions/cache@v4
72-
with:
73-
path: ${{ env.CROSS_BUILD_WASI }}/config.cache
74-
# Should be kept in sync with the other config.cache step above.
75-
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }}
7653
- name: "Configure host"
7754
# `--with-pydebug` inferred from configure-build-python
7855
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ Tools/unicode/data/
134134
/config.log
135135
/config.status
136136
/config.status.lineno
137-
# hendrikmuhs/ccache-action@v1
138137
/.ccache
139138
/cross-build/
140139
/jit_stencils*.h

Lib/statistics.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,14 @@ def stdev(data, xbar=None):
12061206
if n < 2:
12071207
raise StatisticsError('stdev requires at least two data points')
12081208
mss = ss / (n - 1)
1209+
try:
1210+
mss_numerator = mss.numerator
1211+
mss_denominator = mss.denominator
1212+
except AttributeError:
1213+
raise ValueError('inf or nan encountered in data')
12091214
if issubclass(T, Decimal):
1210-
return _decimal_sqrt_of_frac(mss.numerator, mss.denominator)
1211-
return _float_sqrt_of_frac(mss.numerator, mss.denominator)
1215+
return _decimal_sqrt_of_frac(mss_numerator, mss_denominator)
1216+
return _float_sqrt_of_frac(mss_numerator, mss_denominator)
12121217

12131218

12141219
def pstdev(data, mu=None):
@@ -1224,9 +1229,14 @@ def pstdev(data, mu=None):
12241229
if n < 1:
12251230
raise StatisticsError('pstdev requires at least one data point')
12261231
mss = ss / n
1232+
try:
1233+
mss_numerator = mss.numerator
1234+
mss_denominator = mss.denominator
1235+
except AttributeError:
1236+
raise ValueError('inf or nan encountered in data')
12271237
if issubclass(T, Decimal):
1228-
return _decimal_sqrt_of_frac(mss.numerator, mss.denominator)
1229-
return _float_sqrt_of_frac(mss.numerator, mss.denominator)
1238+
return _decimal_sqrt_of_frac(mss_numerator, mss_denominator)
1239+
return _float_sqrt_of_frac(mss_numerator, mss_denominator)
12301240

12311241

12321242
def _mean_stdev(data):

Lib/test/test_perf_profiler.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,24 @@ def test_sys_api_get_status(self):
225225
"""
226226
assert_python_ok("-c", code)
227227

228+
def test_sys_api_perf_jit_backend(self):
229+
code = """if 1:
230+
import sys
231+
sys.activate_stack_trampoline("perf_jit")
232+
assert sys.is_stack_trampoline_active() is True
233+
sys.deactivate_stack_trampoline()
234+
assert sys.is_stack_trampoline_active() is False
235+
"""
236+
assert_python_ok("-c", code, PYTHON_JIT="0")
237+
238+
def test_sys_api_with_existing_perf_jit_trampoline(self):
239+
code = """if 1:
240+
import sys
241+
sys.activate_stack_trampoline("perf_jit")
242+
sys.activate_stack_trampoline("perf_jit")
243+
"""
244+
assert_python_ok("-c", code, PYTHON_JIT="0")
245+
228246

229247
def is_unwinding_reliable_with_frame_pointers():
230248
cflags = sysconfig.get_config_var("PY_CORE_CFLAGS")

Lib/test/test_statistics.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,14 @@ def test_center_not_at_mean(self):
21222122
self.assertEqual(self.func(data), 2.5)
21232123
self.assertEqual(self.func(data, mu=0.5), 6.5)
21242124

2125+
def test_gh_140938(self):
2126+
# Inputs with inf/nan should raise a ValueError
2127+
with self.assertRaises(ValueError):
2128+
self.func([1.0, math.inf])
2129+
with self.assertRaises(ValueError):
2130+
self.func([1.0, math.nan])
2131+
2132+
21252133
class TestSqrtHelpers(unittest.TestCase):
21262134

21272135
def test_integer_sqrt_of_frac_rto(self):
@@ -2240,6 +2248,14 @@ def test_center_not_at_mean(self):
22402248
data = (1.0, 2.0)
22412249
self.assertEqual(self.func(data, xbar=2.0), 1.0)
22422250

2251+
def test_gh_140938(self):
2252+
# Inputs with inf/nan should raise a ValueError
2253+
with self.assertRaises(ValueError):
2254+
self.func([1.0, math.inf])
2255+
with self.assertRaises(ValueError):
2256+
self.func([1.0, math.nan])
2257+
2258+
22432259
class TestGeometricMean(unittest.TestCase):
22442260

22452261
def test_basics(self):

0 commit comments

Comments
 (0)