gh-151221: Fix plistlib loading of partial ISO 8601 dates#151217
gh-151221: Fix plistlib loading of partial ISO 8601 dates#151217JavaZeroo wants to merge 3 commits into
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
b6ad3b9 to
c2c8258
Compare
plistlib's date regex makes the month, day and time components optional, but _date_from_string stopped building the datetime arguments at the first missing component, so a partial date such as ``2024-06Z`` raised a confusing TypeError instead of producing a datetime. Default the omitted components to the start of the period.
c2c8258 to
526bbb5
Compare
|
Please do not force push as required by https://devguide.python.org/getting-started/pull-request-lifecycle/#pullrequest |
Done — added a versionchanged:: next note in the docs. Sorry about the force-pushes, will avoid them from now on. |
Documentation build overview
|
| # Smaller units may be omitted; missing components default to the | ||
| # start of the period. | ||
| for data, expected in [ | ||
| (b"<plist><date>2024Z</date></plist>", |
There was a problem hiding this comment.
I'm not sure if 2024Z is a valid ISO 8601 format. While year only (YYYY) format is ISO, I think timezone designators (in this case Zulu time) can only be attached to complete time value, not a standalone year.
Summary:
Fix
plistlib._date_from_stringraising a confusingTypeErrorwhen a<date>omits smaller units (e.g.2024-06Zor2024Z). The date regex makes month/day/time optional, but the argument list fordatetime.datetime()was truncated at the first missing component. Missing components now default to the start of the period.Add coverage for loading partial dates (year only, year-month, etc.).
Tests: