Skip to content

Fix DM_ISO8601 handling of dates with a zero month or day - #264

Merged
lelit merged 1 commit into
python-rapidjson:masterfrom
espressolee:fix-iso8601-zero-date
Nov 25, 2026
Merged

lelit merged 1 commit into
python-rapidjson:masterfrom
espressolee:fix-iso8601-zero-date

Conversation

@espressolee

@espressolee espressolee commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Reject month 00 and day 00 in IsIso8601Date() before calling days_per_month().
  • Check PyDate_FromDate() for NULL in the bare-date fast path before calling Handle().
  • Add regression coverage for zero month/day at top level, in datetime-shaped strings, and inside objects and arrays.

Invalid ISO-8601-shaped dates now follow the existing fallback behavior and remain Python strings.

Why both checks are included

The range check prevents invalid zero fields from entering date construction. The NULL check protects the container path if date construction fails for another reason and matches the defensive check already used by the neighboring datetime/time path.

Verification

The patch is based on master commit 39996ba9530acde50cef0b82724860ab51819197 and was checked with git apply --check against the current master tip.

  • On an unpatched Python 3.14.3 build, the saved ASan+UBSan input and a plain release reproducer crash in the zero-month/zero-day path.
  • The saved sanitizer input no longer crashes with the patch.
  • The added regression cases cover bare dates, datetime-shaped strings, objects, and arrays.

The earlier local run recorded the complete upstream suite as 1460 passed, 19 skipped, 2 xfailed on both patched release and assertion-enabled builds; the raw pytest logs were not retained, so the repository CI remains the independent confirmation.

@lelit

lelit commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Thanks, I will merge this.

@lelit
lelit merged commit a5edc4b into python-rapidjson:master Nov 25, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants