File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ cellvar
1515cellvars
1616cmpop
1717denom
18+ DICTFLAG
1819dictoffset
1920elts
2021excepthandler
@@ -28,6 +29,7 @@ heaptype
2829HIGHRES
2930IMMUTABLETYPE
3031Itertool
32+ keeped
3133kwonlyarg
3234kwonlyargs
3335lasti
@@ -48,6 +50,7 @@ PYTHREAD_NAME
4850SA_ONSTACK
4951SOABI
5052stackdepth
53+ stginfo
5154stringlib
5255structseq
5356subparams
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments