Visitar URL original
Use UTF-8 lengths for requirement errors by charliermarsh · Pull Request #19781 · astral-sh/uv · GitHub
Skip to content
Merged
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
14 changes: 13 additions & 1 deletion crates/uv-pep508/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ fn parse_extras_cursor<T: Pep508Url>(
"Expected either `,` (separating extras) or `]` (ending the extras section), found `{other}`"
)),
start: pos,
len: 1,
len: other.len_utf8(),
input: cursor.to_string(),
});
}
Expand Down Expand Up @@ -1320,6 +1320,18 @@ mod tests {
);
}

#[test]
fn error_unicode_after_extra() {
assert_snapshot!(
parse_pep508_err("foo[bar α]"),
@"
Expected either `,` (separating extras) or `]` (ending the extras section), found `α`
foo[bar α]
^
"
);
}

#[test]
fn error_extras1() {
let numpy = Requirement::<Url>::from_str("black[d]").unwrap();
Expand Down
Loading