Skip to content

Commit c20c6da

Browse files
Initial
1 parent 72e5b25 commit c20c6da

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Lib/_strptime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import time
1515
import locale
1616
import calendar
17+
from re import A as re_A
1718
from re import compile as re_compile
1819
from re import sub as re_sub
1920
from re import IGNORECASE
@@ -380,7 +381,7 @@ def repl(m):
380381

381382
def compile(self, format):
382383
"""Return a compiled re object for the format string."""
383-
return re_compile(self.pattern(format), IGNORECASE)
384+
return re_compile(self.pattern(format), IGNORECASE | re_A)
384385

385386
_cache_lock = _thread_allocate_lock()
386387
# DO NOT modify _TimeRE_cache or _regex_cache without acquiring the cache lock

Lib/test/datetimetester.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,6 +2916,9 @@ def test_strptime(self):
29162916
with self.assertRaises(ValueError): strptime("-000", "%z")
29172917
with self.assertRaises(ValueError): strptime("z", "%z")
29182918

2919+
# test only ascii is allowed
2920+
with self.assertRaises(ValueError): strptime('٢025-03-09', '%Y-%m-%d')
2921+
29192922
def test_strptime_single_digit(self):
29202923
# bpo-34903: Check that single digit dates and times are allowed.
29212924

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`datetime.strptime` now only accepts ASCII input.

0 commit comments

Comments
 (0)