mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
fix buffer (#6447)
This commit is contained in:
1 parent
65bdfc3d4e
commit
aef4de4ab8
2 files changed
+19
-3
No files matched your search
@@ -15,6 +15,7 @@ cellvar
|
||||
cellvars
|
||||
cmpop
|
||||
denom
|
||||
DICTFLAG
|
||||
dictoffset
|
||||
elts
|
||||
excepthandler
|
||||
@@ -28,6 +29,7 @@ heaptype
|
||||
HIGHRES
|
||||
IMMUTABLETYPE
|
||||
Itertool
|
||||
keeped
|
||||
kwonlyarg
|
||||
kwonlyargs
|
||||
lasti
|
||||
@@ -48,6 +50,7 @@ PYTHREAD_NAME
|
||||
SA_ONSTACK
|
||||
SOABI
|
||||
stackdepth
|
||||
stginfo
|
||||
stringlib
|
||||
structseq
|
||||
subparams
|
||||
|
||||
+16
-3
@@ -238,10 +238,23 @@ impl FormatCode {
|
||||
_ => 1,
|
||||
};
|
||||
|
||||
// Skip whitespace (Python ignores whitespace in format strings)
|
||||
while let Some(b' ' | b'\t' | b'\n' | b'\r') = chars.peek() {
|
||||
chars.next();
|
||||
}
|
||||
|
||||
// determine format char:
|
||||
let c = chars
|
||||
.next()
|
||||
.ok_or_else(|| "repeat count given without format specifier".to_owned())?;
|
||||
let c = match chars.next() {
|
||||
Some(c) => c,
|
||||
None => {
|
||||
// If we have a repeat count but only whitespace follows, error
|
||||
if repeat != 1 {
|
||||
return Err("repeat count given without format specifier".to_owned());
|
||||
}
|
||||
// Otherwise, we're done parsing
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// Check for embedded null character
|
||||
if c == 0 {
|
||||
|
||||
Reference in new issue
Block a user