Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix cspell warnings
  • Loading branch information
youknowone committed Jun 27, 2025
commit 3673372d3d781cafcc51d5cab763fbfb85732671
2 changes: 2 additions & 0 deletions .cspell.dict/cpython.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ SA_ONSTACK
stackdepth
stringlib
structseq
subparams
tok_oldval
tvars
unaryop
unparse
unparser
Expand Down
6 changes: 6 additions & 0 deletions .cspell.dict/python-more.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ getrandom
getrecursionlimit
getrefcount
getsizeof
getswitchinterval
getweakrefcount
getweakrefs
getwindowsversion
Expand Down Expand Up @@ -167,13 +168,17 @@ pycs
pyexpat
PYTHONBREAKPOINT
PYTHONDEBUG
PYTHONDONTWRITEBYTECODE
PYTHONHASHSEED
PYTHONHOME
PYTHONINSPECT
PYTHONINTMAXSTRDIGITS
PYTHONNOUSERSITE
PYTHONOPTIMIZE
PYTHONPATH
PYTHONPATH
PYTHONSAFEPATH
PYTHONUNBUFFERED
PYTHONVERBOSE
PYTHONWARNDEFAULTENCODING
PYTHONWARNINGS
Expand Down Expand Up @@ -206,6 +211,7 @@ seennl
setattro
setcomp
setrecursionlimit
setswitchinterval
showwarnmsg
signum
slotnames
Expand Down
4 changes: 4 additions & 0 deletions .cspell.dict/rust-more.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ arrayvec
bidi
biguint
bindgen
bitand
bitflags
bitor
bitxor
bstr
byteorder
byteset
Expand All @@ -15,6 +17,7 @@ cranelift
cstring
datelike
deserializer
deserializers
fdiv
flamescope
flate2
Expand All @@ -31,6 +34,7 @@ keccak
lalrpop
lexopt
libc
libcall
libloading
libz
longlong
Expand Down
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"GetSet",
"groupref",
"internable",
"jitted",
"jitting",
"lossily",
"makeunicodedata",
"miri",
Expand All @@ -85,6 +87,7 @@
"pygetset",
"pyimpl",
"pylib",
"pymath",
"pymember",
"PyMethod",
"PyModule",
Expand Down
3 changes: 2 additions & 1 deletion common/src/str.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// cspell:ignore uncomputed
use crate::atomic::{PyAtomic, Radium};
use crate::format::CharLen;
use crate::wtf8::{CodePoint, Wtf8, Wtf8Buf};
Expand Down Expand Up @@ -424,7 +425,7 @@ pub fn zfill(bytes: &[u8], width: usize) -> Vec<u8> {
}
}

/// Convert a string to ascii compatible, escaping unicodes into escape
/// Convert a string to ascii compatible, escaping unicode-s into escape
/// sequences.
pub fn to_ascii(value: &str) -> AsciiString {
let mut ascii = Vec::new();
Expand Down
26 changes: 13 additions & 13 deletions compiler/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ impl Compiler<'_> {
// self.jump_to_fail_pop(pc, JumpOp::PopJumpIfFalse)?;
// }

// // Check that the number of subpatterns is not absurd.
// // Check that the number of sub-patterns is not absurd.
// if size.saturating_sub(1) > (i32::MAX as usize) {
// panic!("too many sub-patterns in mapping pattern");
// // return self.compiler_error("too many sub-patterns in mapping pattern");
Expand Down Expand Up @@ -2469,41 +2469,41 @@ impl Compiler<'_> {
emit!(self, Instruction::CopyItem { index: 1_u32 });
self.compile_pattern(alt, pc)?;

let nstores = pc.stores.len();
let n_stores = pc.stores.len();
if i == 0 {
// Save the captured names from the first alternative.
control = Some(pc.stores.clone());
} else {
let control_vec = control.as_ref().unwrap();
if nstores != control_vec.len() {
if n_stores != control_vec.len() {
return Err(self.error(CodegenErrorType::ConflictingNameBindPattern));
} else if nstores > 0 {
} else if n_stores > 0 {
// Check that the names occur in the same order.
for icontrol in (0..nstores).rev() {
let name = &control_vec[icontrol];
for i_control in (0..n_stores).rev() {
let name = &control_vec[i_control];
// Find the index of `name` in the current stores.
let istores =
let i_stores =
pc.stores.iter().position(|n| n == name).ok_or_else(|| {
self.error(CodegenErrorType::ConflictingNameBindPattern)
})?;
if icontrol != istores {
if i_control != i_stores {
// The orders differ; we must reorder.
assert!(istores < icontrol, "expected istores < icontrol");
let rotations = istores + 1;
assert!(i_stores < i_control, "expected i_stores < i_control");
let rotations = i_stores + 1;
// Rotate pc.stores: take a slice of the first `rotations` items...
let rotated = pc.stores[0..rotations].to_vec();
// Remove those elements.
for _ in 0..rotations {
pc.stores.remove(0);
}
// Insert the rotated slice at the appropriate index.
let insert_pos = icontrol - istores;
let insert_pos = i_control - i_stores;
for (j, elem) in rotated.into_iter().enumerate() {
pc.stores.insert(insert_pos + j, elem);
}
// Also perform the same rotation on the evaluation stack.
for _ in 0..(istores + 1) {
self.pattern_helper_rotate(icontrol + 1)?;
for _ in 0..(i_stores + 1) {
self.pattern_helper_rotate(i_control + 1)?;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn compile(
source_path: &str,
opts: CompileOpts,
) -> Result<CodeObject, CompileError> {
// TODO: do this less hackily; ruff's parser should translate a CRLF line
// TODO: do this less hacky; ruff's parser should translate a CRLF line
// break in a multiline string into just an LF in the parsed value
#[cfg(windows)]
let source = &source.replace("\r\n", "\n");
Expand Down
1 change: 1 addition & 0 deletions example_projects/frozen_stdlib/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// cspell:ignore aheui
/// Setting up a project with a frozen stdlib can be done *either* by using `rustpython::InterpreterConfig` or `rustpython_vm::Interpreter::with_init`.
/// See each function for example.
///
Expand Down
2 changes: 1 addition & 1 deletion examples/parse_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn parse_folder(path: &Path) -> std::io::Result<Vec<ParsedFile>> {
let parsed_file = parse_python_file(&path);
match &parsed_file.result {
Ok(_) => {}
Err(y) => error!("Erreur in file {path:?} {y:?}"),
Err(y) => error!("Error in file {path:?} {y:?}"),
}

res.push(parsed_file);
Expand Down
4 changes: 2 additions & 2 deletions jit/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ impl StackMachine {
}

pub fn run(&mut self, code: CodeObject) {
let mut oparg_state = OpArgState::default();
let mut op_arg_state = OpArgState::default();
let _ = code.instructions.iter().try_for_each(|&word| {
let (instruction, arg) = oparg_state.get(word);
let (instruction, arg) = op_arg_state.get(word);
self.process_instruction(instruction, arg, &code.constants, &code.names)
});
}
Expand Down
4 changes: 2 additions & 2 deletions jit/tests/float_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn test_power() {
assert_approx_eq!(pow(-4.5, 4.0), Ok(410.0625));
assert_approx_eq!(pow(-2.5, 3.0), Ok(-15.625));
assert_approx_eq!(pow(-2.5, 4.0), Ok(39.0625));
// Test positive float base, positive float exponent with nonintegral exponents
// Test positive float base, positive float exponent with non-integral exponents
assert_approx_eq!(pow(2.0, 2.5), Ok(5.656854249492381));
assert_approx_eq!(pow(3.0, 3.5), Ok(46.76537180435969));
assert_approx_eq!(pow(4.0, 4.5), Ok(512.0));
Expand All @@ -187,7 +187,7 @@ fn test_power() {
assert_approx_eq!(pow(-2.0, -3.0), Ok(-0.125));
assert_approx_eq!(pow(-2.0, -4.0), Ok(0.0625));

// Currently negative float base with nonintegral exponent is not supported:
// Currently negative float base with non-integral exponent is not supported:
// assert_approx_eq!(pow(-2.0, 2.5), Ok(5.656854249492381));
// assert_approx_eq!(pow(-3.0, 3.5), Ok(-46.76537180435969));
// assert_approx_eq!(pow(-4.0, 4.5), Ok(512.0));
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ fn write_profile(settings: &Settings) -> Result<(), Box<dyn std::error::Error>>
Some("html") => ProfileFormat::Html,
Some("text") => ProfileFormat::Text,
None if profile_output == Some("-".as_ref()) => ProfileFormat::Text,
// cspell:ignore speedscope
Some("speedscope") | None => ProfileFormat::SpeedScope,
Some(other) => {
error!("Unknown profile format {}", other);
Expand Down
2 changes: 2 additions & 0 deletions stdlib/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// cspell:ignore ossl osslconf

fn main() {
println!(r#"cargo::rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_COMP"))"#);
println!(r#"cargo::rustc-check-cfg=cfg(openssl_vendored)"#);
Expand Down
2 changes: 1 addition & 1 deletion stdlib/src/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod gc {
}

#[pyfunction]
fn get_refererts(_args: FuncArgs, vm: &VirtualMachine) -> PyResult {
fn get_referents(_args: FuncArgs, vm: &VirtualMachine) -> PyResult {
Err(vm.new_not_implemented_error(""))
}

Expand Down
12 changes: 6 additions & 6 deletions stdlib/src/lzma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod _lzma {
#[pyarg(any, default = FORMAT_AUTO)]
format: i32,
#[pyarg(any, optional)]
memlimit: Option<u64>,
mem_limit: Option<u64>,
#[pyarg(any, optional)]
filters: Option<u32>,
}
Expand All @@ -149,15 +149,15 @@ mod _lzma {
type Args = LZMADecompressorConstructorArgs;

fn py_new(cls: PyTypeRef, args: Self::Args, vm: &VirtualMachine) -> PyResult {
if args.format == FORMAT_RAW && args.memlimit.is_some() {
if args.format == FORMAT_RAW && args.mem_limit.is_some() {
return Err(vm.new_value_error("Cannot specify memory limit with FORMAT_RAW"));
}
let memlimit = args.memlimit.unwrap_or(u64::MAX);
let mem_limit = args.mem_limit.unwrap_or(u64::MAX);
let filters = args.filters.unwrap_or(0);
let stream_result = match args.format {
FORMAT_AUTO => Stream::new_auto_decoder(memlimit, filters),
FORMAT_XZ => Stream::new_stream_decoder(memlimit, filters),
FORMAT_ALONE => Stream::new_lzma_decoder(memlimit),
FORMAT_AUTO => Stream::new_auto_decoder(mem_limit, filters),
FORMAT_XZ => Stream::new_stream_decoder(mem_limit, filters),
FORMAT_ALONE => Stream::new_lzma_decoder(mem_limit),
// TODO: FORMAT_RAW
_ => return Err(new_lzma_error("Invalid format", vm)),
};
Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct PyDescriptorOwned {
pub struct PyMethodDescriptor {
pub common: PyDescriptor,
pub method: &'static PyMethodDef,
// vectorcall: vectorcallfunc,
// vectorcall: vector_call_func,
pub objclass: &'static Py<PyType>, // TODO: move to tp_members
}

Expand Down
10 changes: 5 additions & 5 deletions vm/src/builtins/function.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "jit")]
mod jitfunc;
mod jit;

use super::{
PyAsyncGen, PyCode, PyCoroutine, PyDictRef, PyGenerator, PyStr, PyStrRef, PyTupleRef, PyType,
Expand Down Expand Up @@ -324,7 +324,7 @@ impl PyFunction {
) -> PyResult {
#[cfg(feature = "jit")]
if let Some(jitted_code) = self.jitted_code.get() {
match jitfunc::get_jit_args(self, &func_args, jitted_code, vm) {
match jit::get_jit_args(self, &func_args, jitted_code, vm) {
Ok(args) => {
return Ok(args.invoke().to_pyobject(vm));
}
Expand Down Expand Up @@ -530,10 +530,10 @@ impl PyFunction {
fn __jit__(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult<()> {
zelf.jitted_code
.get_or_try_init(|| {
let arg_types = jitfunc::get_jit_arg_types(&zelf, vm)?;
let ret_type = jitfunc::jit_ret_type(&zelf, vm)?;
let arg_types = jit::get_jit_arg_types(&zelf, vm)?;
let ret_type = jit::jit_ret_type(&zelf, vm)?;
rustpython_jit::compile(&zelf.code.code, &arg_types, ret_type)
.map_err(|err| jitfunc::new_jit_error(err.to_string(), vm))
.map_err(|err| jit::new_jit_error(err.to_string(), vm))
})
.map(drop)
}
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions vm/src/builtins/genericalias.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// cspell:ignore iparam
use std::sync::LazyLock;

use super::type_;
Expand Down
4 changes: 2 additions & 2 deletions vm/src/builtins/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ pub struct PyModuleDef {
// pub size: isize,
pub methods: &'static [PyMethodDef],
pub slots: PyModuleSlots,
// traverse: traverseproc
// traverse: traverse_proc
// clear: inquiry
// free: freefunc
// free: free_func
}

pub type ModuleCreate =
Expand Down
4 changes: 2 additions & 2 deletions vm/src/builtins/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ fn object_getstate_default(obj: &PyObject, required: bool, vm: &VirtualMachine)

if required {
let mut basicsize = obj.class().slots.basicsize;
// if obj.class().slots.dictoffset > 0
// if obj.class().slots.dict_offset > 0
// && !obj.class().slots.flags.has_feature(PyTypeFlags::MANAGED_DICT)
// {
// basicsize += std::mem::size_of::<PyObjectRef>();
// }
// if obj.class().slots.weaklistoffset > 0 {
// if obj.class().slots.weaklist_offset > 0 {
// basicsize += std::mem::size_of::<PyObjectRef>();
// }
if let Some(ref slot_names) = slot_names {
Expand Down
5 changes: 5 additions & 0 deletions vm/src/builtins/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ impl PyStr {
fn _compute_hash(&self, vm: &VirtualMachine) -> hash::PyHash {
let hash_val = vm.state.hash_secret.hash_bytes(self.as_bytes());
debug_assert_ne!(hash_val, hash::SENTINEL);
// cspell:ignore cmpxchg
// like with char_len, we don't need a cmpxchg loop, since it'll always be the same value
self.hash.store(hash_val, atomic::Ordering::Relaxed);
hash_val
Expand Down Expand Up @@ -2259,7 +2260,9 @@ mod tests {
("Format This As Title String", "fOrMaT thIs aS titLe String"),
("Format,This-As*Title;String", "fOrMaT,thIs-aS*titLe;String"),
("Getint", "getInt"),
// cspell:disable-next-line
("Greek Ωppercases ...", "greek ωppercases ..."),
// cspell:disable-next-line
("Greek ῼitlecases ...", "greek ῳitlecases ..."),
];
for (title, input) in tests {
Expand All @@ -2274,7 +2277,9 @@ mod tests {
"A Titlecased Line",
"A\nTitlecased Line",
"A Titlecased, Line",
// cspell:disable-next-line
"Greek Ωppercases ...",
// cspell:disable-next-line
"Greek ῼitlecases ...",
];

Expand Down
8 changes: 4 additions & 4 deletions vm/src/function/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ impl FuncArgs {
{
// last `kwarg_names.len()` elements of args in order of appearance in the call signature
let total_argc = args.len();
let kwargc = kwarg_names.len();
let posargc = total_argc - kwargc;
let kwarg_count = kwarg_names.len();
let pos_arg_count = total_argc - kwarg_count;

let posargs = args.by_ref().take(posargc).collect();
let pos_args = args.by_ref().take(pos_arg_count).collect();

let kwargs = kwarg_names.zip_eq(args).collect::<IndexMap<_, _>>();

FuncArgs {
args: posargs,
args: pos_args,
kwargs,
}
}
Expand Down
2 changes: 1 addition & 1 deletion vm/src/function/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const fn zst_ref_out_of_thin_air<T: 'static>(x: T) -> &'static T {
}

/// Get the STATIC_FUNC of the passed function. The same
/// requirements of zero-sizedness apply, see that documentation for details.
/// requirements of zero-sized-ness apply, see that documentation for details.
///
/// Equivalent to [`IntoPyNativeFn::into_func()`], but usable in a const context. This is only
/// valid if the function is zero-sized, i.e. that `std::mem::size_of::<F>() == 0`. If you call
Expand Down
Loading
Loading