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

[3.14] gh-136028: Fix parsing month names containing "İ" (U+0130) in strptime() (GH-136029)#136037

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

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
12 changes: 10 additions & 2 deletionsLib/_strptime.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,6 +42,14 @@ def _findall(haystack, needle):
yield i
i += len(needle)

def _fixmonths(months):
yield from months
# The lower case of 'İ' ('\u0130') is 'i\u0307'.
# The re module only supports 1-to-1 character matching in
# case-insensitive mode.
for s in months:
if 'i\u0307' in s:
yield s.replace('i\u0307', '\u0130')

lzh_TW_alt_digits = (
# 〇:一:二:三:四:五:六:七:八:九
Expand DownExpand Up@@ -366,8 +374,8 @@ def __init__(self, locale_time=None):
'z': r"(?P<z>[+-]\d\d:?[0-5]\d(:?[0-5]\d(\.\d{1,6})?)?|(?-i:Z))",
'A': self.__seqToRE(self.locale_time.f_weekday, 'A'),
'a': self.__seqToRE(self.locale_time.a_weekday, 'a'),
'B': self.__seqToRE(self.locale_time.f_month[1:], 'B'),
'b': self.__seqToRE(self.locale_time.a_month[1:], 'b'),
'B': self.__seqToRE(_fixmonths(self.locale_time.f_month[1:]), 'B'),
'b': self.__seqToRE(_fixmonths(self.locale_time.a_month[1:]), 'b'),
'p': self.__seqToRE(self.locale_time.am_pm, 'p'),
'Z': self.__seqToRE((tz for tz_names in self.locale_time.timezone
for tz in tz_names),
Expand Down
9 changes: 9 additions & 0 deletionsLib/test/test_strptime.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -337,6 +337,15 @@ def test_month_locale(self):
self.roundtrip('%B', 1, (1900, m, 1, 0, 0, 0, 0, 1, 0))
self.roundtrip('%b', 1, (1900, m, 1, 0, 0, 0, 0, 1, 0))

@run_with_locales('LC_TIME', 'az_AZ', 'ber_DZ', 'ber_MA', 'crh_UA')
def test_month_locale2(self):
# Test for month directives
# Month name contains 'İ' ('\u0130')
self.roundtrip('%B', 1, (2025, 6, 1, 0, 0, 0, 6, 152, 0))
self.roundtrip('%b', 1, (2025, 6, 1, 0, 0, 0, 6, 152, 0))
self.roundtrip('%B', 1, (2025, 7, 1, 0, 0, 0, 1, 182, 0))
self.roundtrip('%b', 1, (2025, 7, 1, 0, 0, 0, 1, 182, 0))

def test_day(self):
# Test for day directives
self.roundtrip('%d %Y', 2)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
Fix parsing month names containing "İ" (U+0130, LATIN CAPITAL LETTER I WITH
DOT ABOVE) in:func:`time.strptime`. This affects locales az_AZ, ber_DZ,
ber_MA and crh_UA.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp