From 9b267554198180cd6b0c545fec6955838c74afb0 Mon Sep 17 00:00:00 2001 From: Ashwin Naren <arihant2math@gmail.com> Date: Mon, 31 Mar 2025 12:11:04 -0700 Subject: [PATCH 1/5] rust dependency updates --- Cargo.lock | 246 +++++++++++++++++++++++++++---------- Cargo.toml | 14 +-- benches/execution.rs | 8 +- benches/microbenchmarks.rs | 8 +- stdlib/Cargo.toml | 2 +- stdlib/src/binascii.rs | 12 +- 6 files changed, 205 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60f0c44ce1..9ffadb13f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,6 +57,56 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +dependencies = [ + "anstyle", + "once_cell", + "windows-sys 0.59.0", +] + [[package]] name = "anyhow" version = "1.0.97" @@ -112,9 +162,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "base64" -version = "0.13.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bindgen" @@ -125,7 +175,7 @@ dependencies = [ "bitflags 2.9.0", "cexpr", "clang-sys", - "itertools 0.11.0", + "itertools 0.13.0", "log", "prettyplease", "proc-macro2", @@ -238,9 +288,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.17" +version = "1.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "525046617d8376e3db1deffb079e91cef90a89fc3ca5c185bbf8c9ecdd15cd5c" dependencies = [ "shlex", ] @@ -311,6 +361,12 @@ dependencies = [ "error-code", ] +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + [[package]] name = "compact_str" version = "0.8.1" @@ -435,7 +491,7 @@ dependencies = [ "rustc-hash", "serde", "smallvec", - "target-lexicon 0.13.2", + "target-lexicon", ] [[package]] @@ -481,7 +537,7 @@ dependencies = [ "cranelift-codegen", "log", "smallvec", - "target-lexicon 0.13.2", + "target-lexicon", ] [[package]] @@ -505,7 +561,7 @@ dependencies = [ "libc", "log", "region", - "target-lexicon 0.13.2", + "target-lexicon", "wasmtime-jit-icache-coherence", "windows-sys 0.59.0", ] @@ -529,7 +585,7 @@ checksum = "e5b09bdd6407bf5d89661b80cf926ce731c9e8cc184bf49102267a2369a8358e" dependencies = [ "cranelift-codegen", "libc", - "target-lexicon 0.13.2", + "target-lexicon", ] [[package]] @@ -728,15 +784,27 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" +[[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" -version = "0.9.3" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" dependencies = [ - "atty", + "anstream", + "anstyle", + "env_filter", + "jiff", "log", - "termcolor", ] [[package]] @@ -747,9 +815,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys 0.59.0", @@ -780,7 +848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78" dependencies = [ "cfg-if", - "rustix 1.0.3", + "rustix 1.0.5", "windows-sys 0.59.0", ] @@ -822,12 +890,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", - "libz-rs-sys", + "libz-rs-sys 0.5.0", "miniz_oxide", ] @@ -874,7 +942,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed7131e57abbde63513e0e6636f76668a1ca9798dcae2df4e283cae9ee83859e" dependencies = [ - "rustix 1.0.3", + "rustix 1.0.5", "windows-targets 0.52.6", ] @@ -1024,9 +1092,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown", @@ -1063,6 +1131,12 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -1081,6 +1155,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -1096,6 +1179,30 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jiff" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c102670231191d07d37a35af3eb77f1f0dbf7a71be51a962dcd57ea607be7260" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cdde31a9d349f1b1f51a0b3714a5940ac022976f4b49485fc04be052b183b4c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -1127,9 +1234,9 @@ dependencies = [ [[package]] name = "lambert_w" -version = "1.2.5" +version = "1.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eeec1be8d026f51b1cf70ed28442b9f0ece61ff196cd3a99d8b4492a83a864b" +checksum = "fd4d9b9fa6582f5d77f954729c91c32a7c85834332e470b014d12e1678fd1793" dependencies = [ "num-complex", "num-traits", @@ -1251,7 +1358,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "902bc563b5d65ad9bba616b490842ef0651066a1a1dc3ce1087113ffcb873c8d" dependencies = [ - "zlib-rs", + "zlib-rs 0.4.2", +] + +[[package]] +name = "libz-rs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6489ca9bd760fe9642d7644e827b0c9add07df89857b0416ee15c1cc1a3b8c5a" +dependencies = [ + "zlib-rs 0.5.0", ] [[package]] @@ -1418,9 +1534,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "ff70ce3e48ae43fa075863cef62e8b43b71a4f2382229920e0df362592919430" dependencies = [ "adler2", ] @@ -1623,7 +1739,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.10", + "redox_syscall 0.5.11", "smallvec", "windows-targets 0.52.6", ] @@ -1743,6 +1859,15 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -1754,9 +1879,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.31" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" +checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" dependencies = [ "proc-macro2", "syn 2.0.100", @@ -1783,9 +1908,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.6" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" +checksum = "17da310086b068fbdcefbba30aeb3721d5bb9af8db4987d6735b2183ca567229" dependencies = [ "cfg-if", "indoc", @@ -1801,19 +1926,19 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.6" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" +checksum = "e27165889bd793000a098bb966adc4300c312497ea25cf7a690a9f0ac5aa5fc1" dependencies = [ "once_cell", - "target-lexicon 0.12.16", + "target-lexicon", ] [[package]] name = "pyo3-ffi" -version = "0.22.6" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" +checksum = "05280526e1dbf6b420062f3ef228b78c0c54ba94e157f5cb724a609d0f2faabc" dependencies = [ "libc", "pyo3-build-config", @@ -1821,9 +1946,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.6" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" +checksum = "5c3ce5686aa4d3f63359a5100c62a127c9f15e8398e5fdeb5deef1fed5cd5f44" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -1833,9 +1958,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.6" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" +checksum = "f4cf6faa0cbfb0ed08e89beb8103ae9724eb4750e3a78084ba4017cbe94f3855" dependencies = [ "heck", "proc-macro2", @@ -1963,9 +2088,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ "bitflags 2.9.0", ] @@ -1983,9 +2108,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145c1c267e14f20fb0f88aa76a1c5ffec42d592c1d28b3cd9148ae35916158d3" +checksum = "dc06e6b318142614e4a48bc725abbf08ff166694835c43c9dae5a9009704639a" dependencies = [ "allocator-api2", "bumpalo", @@ -2139,9 +2264,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ "bitflags 2.9.0", "errno", @@ -2371,7 +2496,7 @@ dependencies = [ "junction", "libc", "libsqlite3-sys", - "libz-rs-sys", + "libz-rs-sys 0.4.2", "mac_address", "malachite-bigint", "md-5", @@ -2691,9 +2816,9 @@ checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "socket2" @@ -2796,12 +2921,6 @@ dependencies = [ "libc", ] -[[package]] -name = "target-lexicon" -version = "0.12.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" - [[package]] name = "target-lexicon" version = "0.13.2" @@ -2817,15 +2936,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "termios" version = "0.3.3" @@ -3662,3 +3772,9 @@ name = "zlib-rs" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b20717f0917c908dc63de2e44e97f1e6b126ca58d0e391cee86d504eb8fbd05" + +[[package]] +name = "zlib-rs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "868b928d7949e09af2f6086dfc1e01936064cc7a819253bce650d4e2a2d63ba8" diff --git a/Cargo.toml b/Cargo.toml index 271c11e782..32d956d38b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,8 @@ log = { workspace = true } flame = { workspace = true, optional = true } lexopt = "0.3" -dirs = { package = "dirs-next", version = "2.0.0" } -env_logger = { version = "0.9.0", default-features = false, features = ["atty", "termcolor"] } +dirs = { package = "dirs-next", version = "2.0" } +env_logger = "0.11" flamescope = { version = "0.1.2", optional = true } [target.'cfg(windows)'.dependencies] @@ -48,7 +48,7 @@ rustyline = { workspace = true } [dev-dependencies] criterion = { workspace = true } -pyo3 = { version = "0.22", features = ["auto-initialize"] } +pyo3 = { version = "0.24", features = ["auto-initialize"] } [[bench]] name = "execution" @@ -154,7 +154,7 @@ ascii = "1.1" bitflags = "2.4.2" bstr = "1" cfg-if = "1.0" -chrono = "0.4.39" +chrono = "0.4" criterion = { version = "0.3.5", features = ["html_reports"] } crossbeam-utils = "0.8.21" flame = "0.2.2" @@ -162,13 +162,13 @@ getrandom = { version = "0.3", features = ["std"] } glob = "0.3" hex = "0.4.3" indexmap = { version = "2.2.6", features = ["std"] } -insta = "1.38.0" +insta = "1.42" itertools = "0.14.0" is-macro = "0.3.7" junction = "1.2.0" -libc = "0.2.169" +libc = "0.2" libffi = "3.2" -log = "0.4.25" +log = "0.4.27" nix = { version = "0.29", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] } malachite-bigint = "0.5" malachite-q = "0.5" diff --git a/benches/execution.rs b/benches/execution.rs index 88e5e3650b..1bc32206c2 100644 --- a/benches/execution.rs +++ b/benches/execution.rs @@ -11,8 +11,8 @@ use std::path::Path; fn bench_cpython_code(b: &mut Bencher, source: &str) { pyo3::Python::with_gil(|py| { b.iter(|| { - let module = pyo3::types::PyModule::from_code_bound(py, source, "", "") - .expect("Error running source"); + let module = + pyo3::types::PyModule::from_code(py, source, "", "").expect("Error running source"); black_box(module); }) }) @@ -53,8 +53,8 @@ pub fn benchmark_file_parsing(group: &mut BenchmarkGroup<WallTime>, name: &str, group.bench_function(BenchmarkId::new("cpython", name), |b| { use pyo3::types::PyAnyMethods; pyo3::Python::with_gil(|py| { - let builtins = pyo3::types::PyModule::import_bound(py, "builtins") - .expect("Failed to import builtins"); + let builtins = + pyo3::types::PyModule::import(py, "builtins").expect("Failed to import builtins"); let compile = builtins.getattr("compile").expect("no compile in builtins"); b.iter(|| { let x = compile diff --git a/benches/microbenchmarks.rs b/benches/microbenchmarks.rs index c62ecf239a..5f04f4bbf8 100644 --- a/benches/microbenchmarks.rs +++ b/benches/microbenchmarks.rs @@ -45,7 +45,7 @@ fn bench_cpython_code(group: &mut BenchmarkGroup<WallTime>, bench: &MicroBenchma // Grab the exec function in advance so we don't have lookups in the hot code let builtins = - pyo3::types::PyModule::import_bound(py, "builtins").expect("Failed to import builtins"); + pyo3::types::PyModule::import(py, "builtins").expect("Failed to import builtins"); let exec = builtins.getattr("exec").expect("no exec in builtins"); let bench_func = |(globals, locals): &mut ( @@ -60,8 +60,8 @@ fn bench_cpython_code(group: &mut BenchmarkGroup<WallTime>, bench: &MicroBenchma }; let bench_setup = |iterations| { - let globals = pyo3::types::PyDict::new_bound(py); - let locals = pyo3::types::PyDict::new_bound(py); + let globals = pyo3::types::PyDict::new(py); + let locals = pyo3::types::PyDict::new(py); if let Some(idx) = iterations { globals.set_item("ITERATIONS", idx).unwrap(); } @@ -99,7 +99,7 @@ fn cpy_compile_code<'a>( name: &str, ) -> pyo3::PyResult<pyo3::Bound<'a, pyo3::types::PyCode>> { let builtins = - pyo3::types::PyModule::import_bound(py, "builtins").expect("Failed to import builtins"); + pyo3::types::PyModule::import(py, "builtins").expect("Failed to import builtins"); let compile = builtins.getattr("compile").expect("no compile in builtins"); compile.call1((code, name, "exec"))?.extract() } diff --git a/stdlib/Cargo.toml b/stdlib/Cargo.toml index 26c85103e5..d4b99ebc92 100644 --- a/stdlib/Cargo.toml +++ b/stdlib/Cargo.toml @@ -43,7 +43,7 @@ num_enum = { workspace = true } parking_lot = { workspace = true } memchr = { workspace = true } -base64 = "0.13.0" +base64 = "0.22" csv-core = "0.1.11" dyn-clone = "1.0.10" puruspe = "0.4.0" diff --git a/stdlib/src/binascii.rs b/stdlib/src/binascii.rs index a8df1fb60b..09e53fd755 100644 --- a/stdlib/src/binascii.rs +++ b/stdlib/src/binascii.rs @@ -16,6 +16,7 @@ mod decl { convert::ToPyException, function::{ArgAsciiBuffer, ArgBytesLike, OptionalArg}, }; + use base64::Engine; use itertools::Itertools; #[pyattr(name = "Error", once)] @@ -263,7 +264,7 @@ mod decl { decoded.len() / 3 * 4 + 1, 0, )), - _ => Err(base64::DecodeError::InvalidLength), + _ => Err(base64::DecodeError::InvalidLength(quad_pos)), } }) .map_err(|err| super::Base64DecodeError(err).to_pyexception(vm)) @@ -272,7 +273,9 @@ mod decl { #[pyfunction] fn b2a_base64(data: ArgBytesLike, NewlineArg { newline }: NewlineArg) -> Vec<u8> { // https://stackoverflow.com/questions/63916821 - let mut encoded = data.with_ref(|b| base64::encode(b)).into_bytes(); + let mut encoded = data + .with_ref(|b| base64::engine::general_purpose::STANDARD.encode(b)) + .into_bytes(); if newline { encoded.push(b'\n'); } @@ -745,7 +748,7 @@ fn new_binascii_error(msg: String, vm: &VirtualMachine) -> PyBaseExceptionRef { impl ToPyException for Base64DecodeError { fn to_pyexception(&self, vm: &VirtualMachine) -> PyBaseExceptionRef { use base64::DecodeError::*; - let message = match self.0 { + let message = match &self.0 { InvalidByte(0, PAD) => "Leading padding not allowed".to_owned(), InvalidByte(_, PAD) => "Discontinuous padding not allowed".to_owned(), InvalidByte(_, _) => "Only base64 data is allowed".to_owned(), @@ -756,7 +759,8 @@ impl ToPyException for Base64DecodeError { length ) } - InvalidLength => "Incorrect padding".to_owned(), + InvalidLength(_) => "Incorrect length".to_owned(), + InvalidPadding => "Incorrect padding".to_owned(), }; new_binascii_error(format!("error decoding base64: {message}"), vm) } From 8700208c2c645660d866b66121a58fedb8aca38e Mon Sep 17 00:00:00 2001 From: Ashwin Naren <arihant2math@gmail.com> Date: Sat, 5 Apr 2025 13:11:39 -0700 Subject: [PATCH 2/5] fix cstr --- benches/execution.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benches/execution.rs b/benches/execution.rs index 1bc32206c2..7a90b678f5 100644 --- a/benches/execution.rs +++ b/benches/execution.rs @@ -12,7 +12,7 @@ fn bench_cpython_code(b: &mut Bencher, source: &str) { pyo3::Python::with_gil(|py| { b.iter(|| { let module = - pyo3::types::PyModule::from_code(py, source, "", "").expect("Error running source"); + pyo3::types::PyModule::from_code(py, source , c"", c"").expect("Error running source"); black_box(module); }) }) From 39e7c275f7cc6723c879b3fe22153c8813e675fa Mon Sep 17 00:00:00 2001 From: Ashwin Naren <arihant2math@gmail.com> Date: Sat, 5 Apr 2025 13:13:27 -0700 Subject: [PATCH 3/5] fix binascii --- stdlib/src/binascii.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/src/binascii.rs b/stdlib/src/binascii.rs index 09e53fd755..319aece82a 100644 --- a/stdlib/src/binascii.rs +++ b/stdlib/src/binascii.rs @@ -759,7 +759,8 @@ impl ToPyException for Base64DecodeError { length ) } - InvalidLength(_) => "Incorrect length".to_owned(), + // TODO: clean up errors + InvalidLength(_) => "Incorrect padding".to_owned(), InvalidPadding => "Incorrect padding".to_owned(), }; new_binascii_error(format!("error decoding base64: {message}"), vm) From f496f92af71528fd800e528c8bad58b9a53ede5e Mon Sep 17 00:00:00 2001 From: Ashwin Naren <arihant2math@gmail.com> Date: Sun, 6 Apr 2025 17:56:09 -0700 Subject: [PATCH 4/5] fix cstr --- benches/execution.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/benches/execution.rs b/benches/execution.rs index 7a90b678f5..956975c22f 100644 --- a/benches/execution.rs +++ b/benches/execution.rs @@ -9,10 +9,12 @@ use std::collections::HashMap; use std::path::Path; fn bench_cpython_code(b: &mut Bencher, source: &str) { + let c_str_source_head = std::ffi::CString::new(source).unwrap(); + let c_str_source = c_str_source_head.as_c_str(); pyo3::Python::with_gil(|py| { b.iter(|| { - let module = - pyo3::types::PyModule::from_code(py, source , c"", c"").expect("Error running source"); + let module = pyo3::types::PyModule::from_code(py, c_str_source, c"", c"") + .expect("Error running source"); black_box(module); }) }) From 6d7becd7fe65a5f9d9ce42db923f7508150071af Mon Sep 17 00:00:00 2001 From: Ashwin Naren <arihant2math@gmail.com> Date: Thu, 10 Apr 2025 18:11:16 -0700 Subject: [PATCH 5/5] address comments --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 32d956d38b..74fdf7464e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,7 +154,7 @@ ascii = "1.1" bitflags = "2.4.2" bstr = "1" cfg-if = "1.0" -chrono = "0.4" +chrono = "0.4.39" criterion = { version = "0.3.5", features = ["html_reports"] } crossbeam-utils = "0.8.21" flame = "0.2.2" @@ -166,7 +166,7 @@ insta = "1.42" itertools = "0.14.0" is-macro = "0.3.7" junction = "1.2.0" -libc = "0.2" +libc = "0.2.169" libffi = "3.2" log = "0.4.27" nix = { version = "0.29", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] }