Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
StanFromIreland wants to merge23 commits intopython:main
base:main
Choose a base branch
Loading
fromStanFromIreland:ascii-strptime
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
23 commits
Select commitHold shift + click to select a range
c20c6da
Initial
StanFromIrelandMar 9, 2025
decd90f
Fix NEWS
StanFromIrelandMar 9, 2025
81276eb
sggestion
StanFromIrelandMar 9, 2025
0a3e67b
Alphabetical order…
StanFromIrelandMar 9, 2025
5d1d53d
Benedikts suggestions
StanFromIrelandMar 9, 2025
a0b0f07
Add docs and tests for time.strptime
StanFromIrelandMar 9, 2025
d0e6a1f
Cover the majority
StanFromIrelandMar 10, 2025
2f6d8e2
Cover all
StanFromIrelandMar 10, 2025
ccabadf
Clean up
StanFromIrelandMar 10, 2025
35bc090
Benedikt's Doc suggestions
StanFromIrelandMar 12, 2025
0637c29
Apply suggestions from code review
StanFromIrelandMar 15, 2025
71d7c8a
Re-word news
StanFromIrelandMar 15, 2025
212c763
Apply suggestions from code review
StanFromIrelandMar 15, 2025
0201347
PEP 8
StanFromIrelandMar 15, 2025
bebb241
REQUESTED CHANGES
StanFromIrelandMar 23, 2025
40d2368
Refactor documentation changes
pganssleMar 26, 2025
77c936a
Clarify non-ASCII parsing in news
pganssleMar 26, 2025
e652581
fixup! Refactor documentation changes
pganssleMar 26, 2025
0115ee4
Unrequire ascii
StanFromIrelandMar 26, 2025
25a6705
Merge branch 'main' into ascii-strptime
StanFromIrelandApr 24, 2025
3bca8e9
Merge branch 'main' into ascii-strptime
pganssleMay 19, 2025
ddd1d01
Adjust documentation to be specific about where non-ASCII digits are …
pganssleMay 19, 2025
0139e57
Move whatsnew
StanFromIrelandMay 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Refactor documentation changes
  • Loading branch information
@pganssle
pganssle committedMar 26, 2025
commit40d2368744a38e574b0d2917bb977c336a6c64a0
5 changes: 2 additions & 3 deletionsDoc/library/datetime.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2617,8 +2617,6 @@ differences between platforms in handling of unsupported format specifiers.
Technical Detail
^^^^^^^^^^^^^^^^

A :exc:`ValueError` will be raised if digits are not ASCII.

Broadly speaking, ``d.strftime(fmt)`` acts like the :mod:`time` module's
``time.strftime(fmt, d.timetuple())`` although not all objects support a
:meth:`~date.timetuple` method.
Expand DownExpand Up@@ -2655,7 +2653,8 @@ Notes:
Because the format depends on the current locale, care should be taken when
making assumptions about the output value. Field orderings will vary (for
example, "month/day/year" versus "day/month/year"), and the output may
contain non-ASCII characters.
contain non-ASCII characters. :meth:`~.datetime.strptime` rejects non-ASCII
digits for non-locale-specific numeric format codes (e.g. `%Y`, `%H`, etc).

(2)
The :meth:`~.datetime.strptime` method can parse years in the full [1, 9999] range, but
Expand Down
6 changes: 4 additions & 2 deletionsDoc/library/time.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -431,8 +431,7 @@ Functions
:func:`gmtime` or :func:`localtime` to a string as specified by the *format*
argument. If *t* is not provided, the current time as returned by
:func:`localtime` is used. *format* must be a string. :exc:`ValueError` is
raised if any field in *t* is outside of the allowed range or if digits are
not ASCII.
raised if any field in *t* is outside of the allowed range.

0 is a legal argument for any position in the time tuple; if it is normally
illegal the value is forced to a correct one.
Expand DownExpand Up@@ -564,6 +563,9 @@ Functions
When used with the :func:`strptime` function, ``%U`` and ``%W`` are only used in
calculations when the day of the week and the year are specified.

(5)
The :func:`strptime` function does not accept non-ASCII digits for numeric values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should we mention the "non-locale-specific numeric format codes" here or, since it's not officially supported, we can be a bit lazy?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@pganssle Do you want to do this too? Or should I?


Here is an example, a format for dates compatible with that specified in the
:rfc:`2822` Internet email standard. [1]_ ::

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp