Skip to content

Commit 1e347cd

Browse files
authored
Correct regex A-z typo (#374)
* Correct regex A-z typo * Remove unneeded lines from test * Remove more unneeded... * black
1 parent c99f242 commit 1e347cd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pendulum/formatting/formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+"
3434
r"|[\u0600-\u06FF/]+(\s*?[\u0600-\u06FF]+){1,2}"
3535
)
36-
_MATCH_TIMEZONE = "[A-za-z0-9-+]+(/[A-Za-z0-9-+_]+)?"
36+
_MATCH_TIMEZONE = "[A-Za-z0-9-+]+(/[A-Za-z0-9-+_]+)?"
3737

3838

3939
class Formatter:

tests/datetime/test_from_format.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ def test_from_format_with_timezone():
3636
assert "Europe/London" == d.timezone_name
3737

3838

39+
def test_from_format_with_square_bracket_in_timezone():
40+
with pytest.raises(ValueError, match="^String does not match format"):
41+
pendulum.from_format(
42+
"1975-05-21 22:32:11 Eu[rope/London", "YYYY-MM-DD HH:mm:ss z",
43+
)
44+
45+
3946
def test_from_format_with_escaped_elements():
4047
d = pendulum.from_format("1975-05-21T22:32:11+00:00", "YYYY-MM-DD[T]HH:mm:ssZ")
4148
assert_datetime(d, 1975, 5, 21, 22, 32, 11)

0 commit comments

Comments
 (0)