X Tutup
Skip to content

Commit aef4de4

Browse files
authored
fix buffer (#6447)
1 parent 65bdfc3 commit aef4de4

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.cspell.dict/cpython.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cellvar
1515
cellvars
1616
cmpop
1717
denom
18+
DICTFLAG
1819
dictoffset
1920
elts
2021
excepthandler
@@ -28,6 +29,7 @@ heaptype
2829
HIGHRES
2930
IMMUTABLETYPE
3031
Itertool
32+
keeped
3133
kwonlyarg
3234
kwonlyargs
3335
lasti
@@ -48,6 +50,7 @@ PYTHREAD_NAME
4850
SA_ONSTACK
4951
SOABI
5052
stackdepth
53+
stginfo
5154
stringlib
5255
structseq
5356
subparams

crates/vm/src/buffer.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,23 @@ impl FormatCode {
238238
_ => 1,
239239
};
240240

241+
// Skip whitespace (Python ignores whitespace in format strings)
242+
while let Some(b' ' | b'\t' | b'\n' | b'\r') = chars.peek() {
243+
chars.next();
244+
}
245+
241246
// determine format char:
242-
let c = chars
243-
.next()
244-
.ok_or_else(|| "repeat count given without format specifier".to_owned())?;
247+
let c = match chars.next() {
248+
Some(c) => c,
249+
None => {
250+
// If we have a repeat count but only whitespace follows, error
251+
if repeat != 1 {
252+
return Err("repeat count given without format specifier".to_owned());
253+
}
254+
// Otherwise, we're done parsing
255+
break;
256+
}
257+
};
245258

246259
// Check for embedded null character
247260
if c == 0 {

0 commit comments

Comments
 (0)
X Tutup