Skip to content

Commit a2c11aa

Browse files
Optional Unicode 3.2.0 but enabled by default (#9011)
Useful for smaller builds, like WebAssembly. The UCD 3.2.0 path is only directly used in a handful of places in Python. Assisted-by: GPT-5.6-Luna
1 parent bf404e0 commit a2c11aa

24 files changed

Lines changed: 145 additions & 89 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
env:
22-
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,doc
23-
CARGO_ARGS_NO_SSL: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,host_env,doc
22+
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls-aws-lc,host_env,doc,ucd_3_2_0
23+
CARGO_ARGS_NO_SSL: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,host_env,doc,ucd_3_2_0
2424
CARGO_ARGS_MOST_FEATS: --features capi,encodings,jit,sqlite,threading
2525
# Crates excluded from workspace builds:
2626
# - rustpython_wasm: requires wasm target
@@ -1154,7 +1154,7 @@ jobs:
11541154

11551155
- name: build rustpython
11561156
if: env.RUN_WASM_WASI == 'true'
1157-
run: cargo build --locked --profile wasm-release --target wasm32-wasip1 --no-default-features --features freeze-stdlib,stdlib,stdio,importlib,host_env,doc --verbose
1157+
run: cargo build --locked --profile wasm-release --target wasm32-wasip1 --no-default-features --features freeze-stdlib,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0 --verbose
11581158
- name: run snippets
11591159
if: env.RUN_WASM_WASI == 'true'
11601160
run: |

‎.github/workflows/cron-ci.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- .github/workflows/cron-ci.yaml
1515

1616
env:
17-
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc
17+
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc,ucd_3_2_0
1818

1919
jobs:
2020
# codecov collects code coverage data from the rust tests, python snippets and python test suite.
@@ -42,7 +42,7 @@ jobs:
4242
- run: sudo apt-get update && sudo apt-get -y install lcov
4343

4444
- name: Run cargo-llvm-cov with Rust tests.
45-
run: cargo llvm-cov --no-report --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi --verbose --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc
45+
run: cargo llvm-cov --no-report --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi --verbose --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls-aws-lc,jit,host_env,doc,ucd_3_2_0
4646

4747
- name: Run cargo-llvm-cov with Python snippets.
4848
run: python scripts/cargo-llvm-cov.py

‎Cargo.toml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license.workspace = true
1111

1212
[features]
1313
capi = ["dep:rustpython-capi", "threading"]
14-
default = ["threading", "stdlib", "stdio", "importlib", "ssl-rustls-aws-lc", "host_env", "mimalloc", "doc"]
14+
default = ["threading", "stdlib", "stdio", "importlib", "ssl-rustls-aws-lc", "host_env", "mimalloc", "doc", "ucd_3_2_0"]
1515
doc = ["rustpython-vm/doc", "rustpython-stdlib?/doc"]
1616
mimalloc = ["dep:mimalloc"]
1717
host_env = ["rustpython-vm/host_env", "rustpython-stdlib?/host_env"]
@@ -32,6 +32,7 @@ ssl-rustls-aws-lc-fips = ["ssl-rustls-aws-lc", "rustls/fips"]
3232
ssl-openssl = ["ssl", "rustpython-stdlib/ssl-openssl"]
3333
ssl-openssl-vendor = ["ssl-openssl", "rustpython-stdlib/ssl-openssl-vendor"]
3434
tkinter = ["rustpython-stdlib/tkinter"]
35+
ucd_3_2_0 = ["rustpython-stdlib?/ucd_3_2_0", "rustpython-capi?/ucd_3_2_0"]
3536

3637
[build-dependencies]
3738
winresource = "0.1"
@@ -169,7 +170,7 @@ repository = "https://github.com/RustPython/RustPython"
169170
license = "MIT"
170171

171172
[workspace.dependencies]
172-
rustpython-capi = { path = "crates/capi", version = "0.6.1" }
173+
rustpython-capi = { path = "crates/capi", version = "0.6.1", default-features = false }
173174
rustpython-compiler-core = { path = "crates/compiler-core", version = "0.6.1" }
174175
rustpython-compiler = { path = "crates/compiler", version = "0.6.1" }
175176
rustpython-codegen = { path = "crates/codegen", version = "0.6.1" }
@@ -183,7 +184,7 @@ rustpython-vm = { path = "crates/vm", default-features = false, version = "0.6.1
183184
rustpython-pylib = { path = "crates/pylib", version = "0.6.1" }
184185
rustpython-stdlib = { path = "crates/stdlib", default-features = false, version = "0.6.1" }
185186
rustpython-sre_engine = { path = "crates/sre_engine", version = "0.6.1" }
186-
rustpython-unicode = { path = "crates/unicode", version = "0.6.1" }
187+
rustpython-unicode = { path = "crates/unicode", default-features = false, version = "0.6.1" }
187188
rustpython-wtf8 = { path = "crates/wtf8", version = "0.6.1" }
188189
rustpython-doc = { path = "crates/doc", version = "0.6.1" }
189190

‎crates/capi/Cargo.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ license.workspace = true
1111
[lib]
1212
crate-type = ["cdylib", "rlib"]
1313

14+
[features]
15+
default = ["ucd_3_2_0"]
16+
ucd_3_2_0 = ["rustpython-stdlib/ucd_3_2_0"]
17+
1418
[dependencies]
1519
bitflags = { workspace = true }
1620
itertools = { workspace = true }

‎crates/common/src/lock.rs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ use lock_api::{
88

99
cfg_select! {
1010
feature = "threading" => {
11+
pub use core::cell::LazyCell;
1112
pub use detaching::{BlockingWaitHook, set_blocking_wait_hook, set_world_stopped};
1213
pub use parking_lot::{RawMutex, RawRwLock, RawThreadId};
1314
pub use std::sync::OnceLock as OnceCell;
14-
pub use core::cell::LazyCell;
1515
}
1616
_ => {
1717
mod cell_lock;
18-
pub use cell_lock::{RawCellMutex as RawMutex, RawCellRwLock as RawRwLock, SingleThreadId as RawThreadId};
18+
pub use cell_lock::{
19+
RawCellMutex as RawMutex, RawCellRwLock as RawRwLock, SingleThreadId as RawThreadId,
20+
};
1921

2022
pub use core::cell::{LazyCell, OnceCell};
2123
}
@@ -37,13 +39,19 @@ cfg_select! {
3739
unsafe impl<T, F> Sync for LazyLock<T, F> {}
3840

3941
impl<T, F: FnOnce() -> T> LazyLock<T, F> {
40-
pub const fn new(f: F) -> Self { Self(core::cell::LazyCell::new(f)) }
41-
pub fn force(this: &Self) -> &T { core::cell::LazyCell::force(&this.0) }
42+
pub const fn new(f: F) -> Self {
43+
Self(core::cell::LazyCell::new(f))
44+
}
45+
pub fn force(this: &Self) -> &T {
46+
core::cell::LazyCell::force(&this.0)
47+
}
4248
}
4349

4450
impl<T, F: FnOnce() -> T> core::ops::Deref for LazyLock<T, F> {
4551
type Target = T;
46-
fn deref(&self) -> &T { &self.0 }
52+
fn deref(&self) -> &T {
53+
&self.0
54+
}
4755
}
4856
}
4957
}

‎crates/stdlib/Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ license.workspace = true
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[features]
14-
default = ["compiler", "host_env", "doc"]
14+
default = ["compiler", "host_env", "doc", "ucd_3_2_0"]
15+
ucd_3_2_0 = ["rustpython-unicode/ucd_3_2_0"]
1516
doc = ["rustpython-vm/doc"]
1617
host_env = ["rustpython-vm/host_env"]
1718
compiler = ["rustpython-vm/compiler"]

‎crates/stdlib/src/_queue.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod _queue {
2121
use parking_lot::{Condvar, Mutex, MutexGuard};
2222

2323
type Buf = Mutex<BufInner>;
24-
},
24+
}
2525
_ => {
2626
use crate::common::lock::PyMutex;
2727

‎crates/stdlib/src/faulthandler.rs‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,9 @@ mod decl {
636636
// frames are still alive because the target thread
637637
// is executing (inside a blocking call).
638638
for (tid, slot) in &thread_frame_slots {
639-
let iframe_ptr = slot
640-
.top_iframe
641-
.load(core::sync::atomic::Ordering::Relaxed)
642-
as *const rustpython_vm::frame::InterpreterFrame;
639+
let iframe_ptr =
640+
slot.top_iframe.load(core::sync::atomic::Ordering::Relaxed)
641+
as *const rustpython_vm::frame::InterpreterFrame;
643642
write_thread_id(fd, *tid, false);
644643
if iframe_ptr.is_null() {
645644
puts(fd, " <no Python frame>\n");
@@ -660,10 +659,9 @@ mod decl {
660659
}
661660
all(not(unix), feature = "threading") => {
662661
for (tid, slot) in &thread_frame_slots {
663-
let iframe_ptr = slot
664-
.top_iframe
665-
.load(core::sync::atomic::Ordering::Relaxed)
666-
as *const rustpython_vm::frame::InterpreterFrame;
662+
let iframe_ptr =
663+
slot.top_iframe.load(core::sync::atomic::Ordering::Relaxed)
664+
as *const rustpython_vm::frame::InterpreterFrame;
667665
write_thread_id(fd, *tid, false);
668666
if iframe_ptr.is_null() {
669667
puts(fd, " <no Python frame>\n");

‎crates/stdlib/src/openssl.rs‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,8 @@ mod _ssl {
13381338
cfg_select! {
13391339
ossl110 => {
13401340
let ctx = zelf.builder();
1341-
let result = unsafe { sys::SSL_CTX_set_num_tickets(ctx.as_ptr(), value as usize) };
1341+
let result =
1342+
unsafe { sys::SSL_CTX_set_num_tickets(ctx.as_ptr(), value as usize) };
13421343
if result != 1 {
13431344
return Err(vm.new_value_error("failed to set num tickets."));
13441345
}
@@ -1360,11 +1361,10 @@ mod _ssl {
13601361
.load_verify_locations(Some(cert_file.as_path()), Some(cert_dir.as_path()))
13611362
.map_err(|e| convert_openssl_error(vm, e))
13621363
}
1363-
_ => {
1364-
zelf.builder()
1365-
.set_default_verify_paths()
1366-
.map_err(|e| convert_openssl_error(vm, e))
1367-
}
1364+
_ => zelf
1365+
.builder()
1366+
.set_default_verify_paths()
1367+
.map_err(|e| convert_openssl_error(vm, e)),
13681368
}
13691369
}
13701370

@@ -2828,11 +2828,9 @@ mod _ssl {
28282828
Ok(())
28292829
}
28302830
}
2831-
_ => {
2832-
Err(vm.new_not_implemented_error(
2833-
"Post-handshake auth is not supported by your OpenSSL version.",
2834-
))
2835-
}
2831+
_ => Err(vm.new_not_implemented_error(
2832+
"Post-handshake auth is not supported by your OpenSSL version.",
2833+
)),
28362834
}
28372835
}
28382836

‎crates/stdlib/src/resource.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ mod resource {
1717

1818
#[cfg_attr(target_os = "android", expect(deprecated))]
1919
const RLIM_NLIMITS: i32 = cfg_select! {
20-
target_os = "android" => {
21-
host_resource::RLIM_NLIMITS
22-
}
20+
target_os = "android" => host_resource::RLIM_NLIMITS,
2321
_ => {
2422
// This constant isn't abi-stable across os versions, so we just
2523
// pick a high number so we don't get false positive ValueErrors and just bubble up the

0 commit comments

Comments
 (0)