Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions crates/vm/src/stdlib/_warnings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mod _warnings {
#[pyarg(any, optional)]
category: OptionalArg<PyObjectRef>,
#[pyarg(any, default = 1)]
stacklevel: i32,
stacklevel: isize,
#[pyarg(any, optional)]
source: OptionalArg<PyObjectRef>,
#[pyarg(named, optional)]
Expand Down Expand Up @@ -127,7 +127,7 @@ mod _warnings {

#[pyfunction]
fn warn(args: WarnArgs, vm: &VirtualMachine) -> PyResult<()> {
let level = args.stacklevel as isize;
let level = args.stacklevel;

let category = get_category(&args.message, args.category.into_option(), vm)?;

Expand Down
8 changes: 2 additions & 6 deletions crates/vm/src/warn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,20 +744,16 @@ fn setup_context(
// Stack level comparisons to Python code is off by one as there is no
// warnings-related stack level to avoid.
if stack_level <= 0 || f.as_ref().is_some_and(|frame| frame.is_internal_frame()) {
while {
while stack_level > 1 {
stack_level -= 1;
stack_level > 0
} {
match f {
Some(tmp) => f = tmp.f_back(vm),
None => break,
}
}
} else {
while {
while stack_level > 1 {
stack_level -= 1;
stack_level > 0
} {
match f {
Some(tmp) => f = next_external_frame_with_skip(&tmp, skip_file_prefixes, vm),
None => break,
Expand Down
Loading