Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-83461: Don't allow datetime parsing to accept non-ASCII digits#131008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes from1 commit
c20c6da
decd90f
81276eb
0a3e67b
5d1d53d
a0b0f07
d0e6a1f
2f6d8e2
ccabadf
35bc090
0637c29
71d7c8a
212c763
0201347
bebb241
40d2368
77c936a
e652581
0115ee4
25a6705
3bca8e9
ddd1d01
0139e57
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2432,7 +2432,8 @@ Class attributes: | ||
:class:`date`, :class:`.datetime`, and :class:`.time` objects all support a | ||
``strftime(format)`` method, to create a string representing the time under the | ||
control of an explicit format string. A :exc:`ValueError` will be raised if digits | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
are not ASCII. | ||
Conversely, the :meth:`date.strptime`, :meth:`datetime.strptime` and | ||
:meth:`time.strptime` class methods create an object from a string | ||
@@ -2612,7 +2613,7 @@ differences between platforms in handling of unsupported format specifiers. | ||
``%:z`` was added. | ||
.. versionchanged:: next | ||
Non-ASCII digits are now rejected by ``strptime`` for numerical directives. | ||
Technical Detail | ||
^^^^^^^^^^^^^^^^ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -594,9 +594,10 @@ Functions | ||
:func:`strftime`; it defaults to ``"%a %b %d %H:%M:%S %Y"`` which matches the | ||
formatting returned by :func:`ctime`. If *string* cannot be parsed according | ||
to *format*, or if it has excess data after parsing, :exc:`ValueError` is | ||
raised. :exc:`ValueError` is raised if digits are not ASCII. The default | ||
values used to fill in any missing data when more accurate values cannot be | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
inferred are ``(1900, 1, 1, 0, 0, 0, 0, 1, -1)``. Both *string* and *format* | ||
must be strings. | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
For example: | ||
@@ -616,6 +617,9 @@ Functions | ||
and thus does not necessarily support all directives available that are not | ||
documented as supported. | ||
.. versionchanged:: next | ||
Non-ASCII digits are now rejected by ``strptime``. | ||
.. class:: struct_time | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -504,10 +504,10 @@ datetime | ||
* Add :meth:`datetime.time.strptime` and :meth:`datetime.date.strptime`. | ||
(Contributed by Wannes Boeykens in :gh:`41431`.) | ||
* The:meth:`datetime.date.strptime`, :meth:`datetime.datetime.strptime` and | ||
:meth:`datetime.time.strptime`methods now only accept ASCII digits, will and | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
raise a :exc:`ValueError` if non-ASCII digits are specified. | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
(Contributed by Stan Ulbrych in :gh:`131008`.) | ||
decimal | ||
------- | ||
@@ -883,6 +883,15 @@ sys.monitoring | ||
* Two new events are added: :monitoring-event:`BRANCH_LEFT` and | ||
:monitoring-event:`BRANCH_RIGHT`. The ``BRANCH`` event is deprecated. | ||
time | ||
---- | ||
* The :meth:`time.strptime`, now only accept ASCII digits, and will raise a | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
:exc:`ValueError` if non-ASCII digits are specified. | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
(Contributed by Stan Ulbrych in :gh:`131008`.) | ||
threading | ||
--------- | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -16,7 +16,7 @@ | ||
import calendar | ||
from re import compile as re_compile | ||
from re import sub as re_sub | ||
from re import IGNORECASE | ||
from re import escape as re_escape | ||
from datetime import (date as datetime_date, | ||
timedelta as datetime_timedelta, | ||
@@ -290,7 +290,7 @@ def __init__(self, locale_time=None): | ||
'f': r"(?P<f>[0-9]{1,6})", | ||
'H': r"(?P<H>2[0-3]|[0-1][0-9]|[0-9])", | ||
'I': r"(?P<I>1[0-2]|0[1-9]|[1-9]| [1-9])", | ||
'G': r"(?P<G>[0-9]{4})", | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page.
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
'j': r"(?P<j>36[0-6]|3[0-5][0-9]|[1-2][0-9][0-9]|0[1-9][0-9]|00[1-9]|[1-9][0-9]|0[1-9]|[1-9])", | ||
'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])", | ||
'M': r"(?P<M>[0-5][0-9]|[0-9])", | ||
@@ -300,8 +300,8 @@ def __init__(self, locale_time=None): | ||
'u': r"(?P<u>[1-7])", | ||
'V': r"(?P<V>5[0-3]|0[1-9]|[1-4][0-9]|[0-9])", | ||
# W is set below by using 'U' | ||
'y': r"(?P<y>[0-9]{2})", | ||
StanFromIreland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
'Y': r"(?P<Y>[0-9]{4})", | ||
'z': r"(?P<z>[+-][0-9][0-9]:?[0-5][0-9](:?[0-5][0-9](\.[0-9]{1,6})?)?|(?-i:Z))", | ||
'A': self.__seqToRE(self.locale_time.f_weekday, 'A'), | ||
'a': self.__seqToRE(self.locale_time.a_weekday, 'a'), | ||
Uh oh!
There was an error while loading.Please reload this page.