Skip to content

Commit ebad76f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into flaky-mp-tests-retry
2 parents 631fb45 + 4f1cf6d commit ebad76f

45 files changed

Lines changed: 1745 additions & 1315 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yaml‎

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ env:
2929
X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR: C:\Program Files\OpenSSL\lib\VC\x64\MD
3030
X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR: C:\Program Files\OpenSSL\include
3131
CARGO_INCREMENTAL: 0
32+
CARGO_PROFILE_TEST_DEBUG: 0
33+
CARGO_PROFILE_DEV_DEBUG: 0
34+
CARGO_PROFILE_RELEASE_DEBUG: 0
3235
CARGO_TERM_COLOR: always
3336

3437
jobs:
@@ -52,9 +55,19 @@ jobs:
5255
with:
5356
components: clippy
5457

55-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
58+
- name: Restore cache
59+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
5660
with:
57-
save-if: ${{ github.ref == 'refs/heads/main' }}
61+
path: |
62+
~/.cargo/bin/
63+
~/.cargo/registry/index/
64+
~/.cargo/registry/cache/
65+
~/.cargo/git/db/
66+
target/
67+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
68+
restore-keys: |
69+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
70+
${{ runner.os }}-stable--
5871
5972
- name: Install macOS dependencies
6073
uses: ./.github/actions/install-macos-deps
@@ -154,7 +167,6 @@ jobs:
154167

155168
- name: Restore cache
156169
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
157-
if: ${{ github.ref != 'refs/heads/main' }} # Never restore on main
158170
with:
159171
path: |
160172
~/.cargo/bin/
@@ -163,9 +175,12 @@ jobs:
163175
~/.cargo/git/db/
164176
target/
165177
# key won't match, will rely on restore-keys
166-
key: cargo-check-${{ runner.os }}-${{ matrix.target }}
178+
key: ${{ runner.os }}-${{ matrix.target }}
167179
restore-keys: |
168-
cargo-check-${{ runner.os }}-${{ matrix.target }}-
180+
${{ runner.os }}-stable-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-
181+
${{ runner.os }}-stable-${{ matrix.target }}-
182+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
183+
${{ runner.os }}-stable--
169184
170185
- uses: dtolnay/rust-toolchain@stable
171186
with:
@@ -194,18 +209,6 @@ jobs:
194209
AR_aarch64_linux_android: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
195210
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang
196211

197-
- name: Save cache
198-
if: ${{ github.ref == 'refs/heads/main' }} # only save on main
199-
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
200-
with:
201-
path: |
202-
~/.cargo/bin/
203-
~/.cargo/registry/index/
204-
~/.cargo/registry/cache/
205-
~/.cargo/git/db/
206-
target/
207-
key: cargo-check-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
208-
209212
snippets_cpython:
210213
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
211214
env:
@@ -252,9 +255,19 @@ jobs:
252255

253256
- uses: dtolnay/rust-toolchain@stable
254257

255-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
258+
- name: Restore cache
259+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
256260
with:
257-
save-if: ${{ github.ref == 'refs/heads/main' }}
261+
path: |
262+
~/.cargo/bin/
263+
~/.cargo/registry/index/
264+
~/.cargo/registry/cache/
265+
~/.cargo/git/db/
266+
target/
267+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
268+
restore-keys: |
269+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
270+
${{ runner.os }}-stable--
258271
259272
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
260273

@@ -364,12 +377,11 @@ jobs:
364377
permissions:
365378
contents: read
366379
checks: write
380+
issues: write
367381
pull-requests: write
368382
security-events: write # for zizmor
369383
steps:
370384
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
371-
with:
372-
persist-credentials: false
373385

374386
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
375387

@@ -385,13 +397,12 @@ jobs:
385397
cargo shear
386398
387399
- name: actionlint
388-
uses: reviewdog/action-actionlint@0d952c597ef8459f634d7145b0b044a9699e5e43 # v1.71.0
400+
uses: reviewdog/action-actionlint@6fb7acc99f4a1008869fa8a0f09cfca740837d9d # v1.72.0
389401

390402
- name: zizmor
391403
uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2
392404

393405
- name: restore prek cache
394-
if: ${{ github.ref != 'refs/heads/main' }} # never restore on main
395406
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
396407
with:
397408
key: prek-${{ hashFiles('.pre-commit-config.yaml') }}
@@ -417,7 +428,6 @@ jobs:
417428
with:
418429
level: warning
419430
fail_level: error
420-
cleanup: false
421431

422432
miri:
423433
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
@@ -436,9 +446,18 @@ jobs:
436446
toolchain: ${{ env.NIGHTLY_CHANNEL }}
437447
components: miri
438448

439-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
449+
- name: Restore cache
450+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
440451
with:
441-
save-if: ${{ github.ref == 'refs/heads/main' }}
452+
path: |
453+
~/.cargo/bin/
454+
~/.cargo/registry/index/
455+
~/.cargo/registry/cache/
456+
~/.cargo/git/db/
457+
target/
458+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
459+
restore-keys: |
460+
${{ runner.os }}-
442461
443462
- name: Run tests under miri
444463
run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test -p rustpython-vm -- miri_test
@@ -461,9 +480,20 @@ jobs:
461480
with:
462481
components: clippy
463482

464-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
483+
- name: Restore cache
484+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
465485
with:
466-
save-if: ${{ github.ref == 'refs/heads/main' }}
486+
path: |
487+
~/.cargo/bin/
488+
~/.cargo/registry/index/
489+
~/.cargo/registry/cache/
490+
~/.cargo/git/db/
491+
target/
492+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
493+
restore-keys: |
494+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
495+
${{ runner.os }}-stable--
496+
${{ runner.os }}-
467497
468498
- name: cargo clippy
469499
run: cargo clippy --manifest-path=crates/wasm/Cargo.toml -- -Dwarnings
@@ -536,9 +566,21 @@ jobs:
536566
with:
537567
target: wasm32-wasip1
538568

539-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
569+
- name: Restore cache
570+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
540571
with:
541-
save-if: ${{ github.ref == 'refs/heads/main' }}
572+
path: |
573+
~/.cargo/bin/
574+
~/.cargo/registry/index/
575+
~/.cargo/registry/cache/
576+
~/.cargo/git/db/
577+
target/
578+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
579+
restore-keys: |
580+
${{ runner.os }}-stable-wasm32-wasip1-${{ hashFiles('**/Cargo.toml') }}-
581+
${{ runner.os }}-stable-wasm32-wasip1-
582+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
583+
${{ runner.os }}-stable--
542584
543585
- name: Setup Wasmer
544586
uses: wasmerio/setup-wasmer@v3
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Update Actions Caches
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
12+
env:
13+
CARGO_INCREMENTAL: 0
14+
CARGO_TERM_COLOR: always
15+
CARGO_PROFILE_TEST_DEBUG: 0
16+
CARGO_PROFILE_DEV_DEBUG: 0
17+
CARGO_PROFILE_RELEASE_DEBUG: 0
18+
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls,host_env,threading,jit
19+
20+
jobs:
21+
build-caches:
22+
name: Build Caches
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix:
26+
include:
27+
- os: macos-latest
28+
toolchain: stable
29+
target: ""
30+
- os: ubuntu-latest
31+
toolchain: stable
32+
target: ""
33+
- os: windows-latest
34+
toolchain: stable
35+
target: ""
36+
steps:
37+
- name: Checkout RustPython main branch
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
39+
with:
40+
repository: RustPython/RustPython
41+
ref: main
42+
persist-credentials: false
43+
44+
- name: Setup Rust
45+
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
46+
with:
47+
toolchain: ${{ matrix.toolchain }}
48+
target: ${{ matrix.target }}
49+
50+
- name: Install macos dependencies
51+
uses: ./.github/actions/install-macos-deps
52+
with:
53+
openssl: true
54+
55+
- name: Build dev cache # dev profile used by check & doc
56+
run: cargo build --profile dev ${{ env.CARGO_ARGS }}
57+
58+
- name: Build test cache
59+
run: cargo build --profile test ${{ env.CARGO_ARGS }}
60+
61+
- name: Build release cache
62+
run: cargo build --profile release ${{ env.CARGO_ARGS }}
63+
64+
- name: Save cache
65+
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
66+
with:
67+
path: |
68+
~/.cargo/bin/
69+
~/.cargo/registry/index/
70+
~/.cargo/registry/cache/
71+
~/.cargo/git/db/
72+
target/
73+
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}

‎Cargo.lock‎

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ insta = "1.46"
190190
itertools = "0.14.0"
191191
is-macro = "0.3.7"
192192
junction = "1.4.2"
193-
libc = "0.2.183"
193+
libc = "0.2.185"
194194
libffi = "5"
195195
log = "0.4.29"
196196
nix = { version = "0.30", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] }

‎Lib/http/cookies.py‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,16 @@ def update(self, values):
337337
key = key.lower()
338338
if key not in self._reserved:
339339
raise CookieError("Invalid attribute %r" % (key,))
340+
if _has_control_character(key, val):
341+
raise CookieError("Control characters are not allowed in "
342+
f"cookies {key!r} {val!r}")
340343
data[key] = val
341344
dict.update(self, data)
342345

346+
def __ior__(self, values):
347+
self.update(values)
348+
return self
349+
343350
def isReservedKey(self, K):
344351
return K.lower() in self._reserved
345352

@@ -365,9 +372,15 @@ def __getstate__(self):
365372
}
366373

367374
def __setstate__(self, state):
368-
self._key = state['key']
369-
self._value = state['value']
370-
self._coded_value = state['coded_value']
375+
key = state['key']
376+
value = state['value']
377+
coded_value = state['coded_value']
378+
if _has_control_character(key, value, coded_value):
379+
raise CookieError("Control characters are not allowed in cookies "
380+
f"{key!r} {value!r} {coded_value!r}")
381+
self._key = key
382+
self._value = value
383+
self._coded_value = coded_value
371384

372385
def output(self, attrs=None, header="Set-Cookie:"):
373386
return "%s %s" % (header, self.OutputString(attrs))
@@ -379,13 +392,16 @@ def __repr__(self):
379392

380393
def js_output(self, attrs=None):
381394
# Print javascript
395+
output_string = self.OutputString(attrs)
396+
if _has_control_character(output_string):
397+
raise CookieError("Control characters are not allowed in cookies")
382398
return """
383399
<script type="text/javascript">
384400
<!-- begin hiding
385401
document.cookie = \"%s\";
386402
// end hiding -->
387403
</script>
388-
""" % (self.OutputString(attrs).replace('"', r'\"'))
404+
""" % (output_string.replace('"', r'\"'))
389405

390406
def OutputString(self, attrs=None):
391407
# Build up our result

0 commit comments

Comments
 (0)