Skip to content

Commit 4525258

Browse files
committed
Fix tests
1 parent fe8a756 commit 4525258

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

babel/messages/catalog.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@ def _has_python_brace_format(string: str) -> bool:
7878
# `fmt.parse` returns 3-or-4-tuples of the form
7979
# `(literal_text, field_name, format_spec, conversion)`;
8080
# if `field_name` is set, this smells like brace format
81-
return any(t[1] is not None for t in fmt.parse(string))
81+
field_name_seen = False
82+
for t in fmt.parse(string):
83+
if t[1] is not None:
84+
field_name_seen = True
85+
# We cannot break here, as we need to consume the whole string
86+
# to ensure that it is a valid format string.
8287
except ValueError:
8388
return False
84-
89+
return field_name_seen
8590

8691
def _parse_datetime_header(value: str) -> datetime.datetime:
8792
match = re.match(r'^(?P<datetime>.*?)(?P<tzoffset>[+-]\d{4})?$', value)

0 commit comments

Comments
 (0)