Skip to content

Conversation

@heoh
Copy link
Contributor

@heoh heoh commented Oct 25, 2025

Description

Fixes a pickle.load failure discovered in pyodide CI (see #62820).

Changed NDArrayBacked.__setstate__ to accept 2-tuple states. When a 2-tuple (data, dtype) is encountered, it is treated as (data, dtype, {}) and normal restoration continues.

@heoh heoh marked this pull request as ready for review October 25, 2025 07:54
@heoh
Copy link
Contributor Author

heoh commented Oct 25, 2025

I'm not sure whether to title the PR "CI" or "BUG".
Any feedback, whether sentence or implementation, is appreciated. :)

@heoh heoh changed the title BUG: Recognize tuple state without attrs dict BUG: Recognize 2-tuple state without attrs dict Oct 25, 2025
if len(state) == 1 and isinstance(state[0], dict):
self.__setstate__(state[0])
return
elif len(state) == 2:
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment that this is hit with pyodide? Also were you able to find any sources why this happens?

Copy link
Contributor Author

@heoh heoh Oct 25, 2025

Choose a reason for hiding this comment

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

Also were you able to find any sources why this happens?

I can't be certain, but it looks likely to be caused by a difference in the Cython compiler version.

Here's how I reasoned:

1. Comparison of the action logs around the time the error occurred

I also suspected the pyodide-build version, but downgrading it myself made no difference. The same was true in #62822, and in the logs below there was even a counterexample where both Passed and Failed appeared on the same 0.30.7 version.

image

However, the Cython compiler versions were different: 3.1.5 -> 3.2.0

2. Cython Update

Around the same time, at 2025-10-22T18:49, a pre-release of Cython was published that includes an update related to pickling.

https://github.com/cython/cython/releases/tag/3.2.0b1-3

  • In auto-pickling, trying to unpickle an object that has no __dict__ from object pickle data
    that includes instance dict state is now an error.
    (Github issue :issue:7222)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems likely that the condition was tightened in the PR below, so that empty dicts are no longer included in the state.

https://github.com/cython/cython/pull/7222/files#diff-81caf3d8e52e1f4c815d4b94458252dcb181f86d3a24ee9f33759a5072837a5bL2335-L2337

Copy link
Contributor Author

@heoh heoh Oct 25, 2025

Choose a reason for hiding this comment

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

Could you add a comment that this is hit with pyodide?

I added a comment. It doesn't seem to be the only cause of the pyodide, so I wrote it in general, and I wrote down the issue number so that it can be tracked instead. (1e6cd2f)

@mroeschke mroeschke added this to the 3.0 milestone Oct 27, 2025
@mroeschke mroeschke added the Bug label Oct 27, 2025
@mroeschke mroeschke merged commit 2736889 into pandas-dev:main Oct 27, 2025
47 checks passed
@mroeschke
Copy link
Member

Thanks @heoh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Pyodide checks failing with NotImplemented error

2 participants