Skip to content

Conversation

charris
Copy link
Member

@charris charris commented Aug 14, 2025

Backport of #29555.

Fixes #29344.

It seems that for datetime dtypes, arraydescr_reduce was initializing a new mapping instead of setting to Py_None, and then arraydescr_setstate just read it in. I set the metadata to and then checked for Py_None and refactored some of the logic to be clearer hopefully.

Adding a test. Thanks for reviewing!

  • BUG: fix metadata not roundtripping for datetime pickles

  • STYLE: Remove unnecessary newline

  • REF: Simplify metadata handling in arraydescr_setstate function

  • TST: add test to ensure datetime dtype metadata round-trips on pickling

  • REF: clearer operation order

  • TST: add new regression test (BUG: Fix metadata not roundtripping when pickling datetime #29555)

  • BUG: don't steal reference to Py_None

  • REF: move metadata variable declarations below for clarity

* BUG: fix metadata not roundtripping for datetime pickles

* STYLE: Remove unnecessary newline

* REF: Simplify metadata handling in arraydescr_setstate function

* TST: add test to ensure datetime dtype metadata round-trips on pickling

* REF: clearer operation order

* TST: add new regression test (numpygh-29555)

* BUG: don't steal reference to Py_None

* REF: move metadata variable declarations below for clarity
@charris charris added this to the 2.3.3 release milestone Aug 14, 2025
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Aug 14, 2025
@charris charris merged commit 03fbe38 into numpy:maintenance/2.3.x Aug 14, 2025
79 of 80 checks passed
@charris charris deleted the backport-29555 branch August 14, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants