Skip to content

Commit

Permalink
Remove use of .previous() in sysconfig parser (#9881)
Browse files Browse the repository at this point in the history
## Summary

Apparently this is only available in debug.
  • Loading branch information
charliermarsh authored Dec 13, 2024
1 parent d8f945a commit dc0525d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions crates/uv-python/src/sysconfig/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl FromStr for SysconfigData {
match next {
'\'' | '"' => {
// Parse key.
let key = parse_string(&mut cursor)?;
let key = parse_string(&mut cursor, next)?;

cursor.eat_while(is_python_whitespace);
cursor.eat_char(':');
Expand Down Expand Up @@ -158,10 +158,7 @@ impl FromStr for SysconfigData {
/// Parse a Python string literal.
///
/// Expects the previous character to be the opening quote character.
fn parse_string(cursor: &mut Cursor) -> Result<String, Error> {
let quote = cursor.previous();
assert!(quote == '\'' || quote == '"', "Invalid quote character");

fn parse_string(cursor: &mut Cursor, quote: char) -> Result<String, Error> {
let mut result = String::new();
loop {
let Some(c) = cursor.bump() else {
Expand Down Expand Up @@ -208,7 +205,7 @@ fn parse_concatenated_string(cursor: &mut Cursor) -> Result<String, Error> {
match c {
'\'' | '"' => {
// Parse a new string fragment and append it.
result.push_str(&parse_string(cursor)?);
result.push_str(&parse_string(cursor, c)?);
}
c if is_python_whitespace(c) => {
// Skip whitespace between fragments
Expand Down

0 comments on commit dc0525d

Please sign in to comment.