mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
removing preceding whitespaces, tabs, and newlines for evals only
This commit is contained in:
1 parent
d7e1322ef9
commit
2fc285f5bc
1 file changed
+9
@@ -256,6 +256,15 @@ mod builtins {
|
||||
));
|
||||
}
|
||||
|
||||
// Check for newlines, tabs, or whitespaces at start
|
||||
let wsp_arr = [9, 10, 32];
|
||||
let mut i = 0;
|
||||
while i < source.len() && wsp_arr.contains(&source[i]) {
|
||||
i = i + 1;
|
||||
}
|
||||
// Slice off whitespaces
|
||||
let source = &source[i..source.len()];
|
||||
|
||||
let source = std::str::from_utf8(source).map_err(|err| {
|
||||
let msg = format!(
|
||||
"(unicode error) 'utf-8' codec can't decode byte 0x{:x?} in position {}: invalid start byte",
|
||||
|
||||
Reference in new issue
Block a user