Skip to content

BUG: fix scipy backend pickling after multiple opens#11339

Open
hansu650 wants to merge 1 commit into
pydata:mainfrom
hansu650:bug/scipy-backend-pickle
Open

BUG: fix scipy backend pickling after multiple opens#11339
hansu650 wants to merge 1 commit into
pydata:mainfrom
hansu650:bug/scipy-backend-pickle

Conversation

@hansu650
Copy link
Copy Markdown

Closes #11323.

This fixes a scipy backend pickling regression when multiple datasets are opened
from file-like objects in the same process.

The scipy backend registers a pickle-visible wrapper class for file-like objects.
Re-registering that class on every open can make an earlier dataset refer to a
class object that no longer matches the registered pickle target. This change
registers the wrapper once and reuses it for later file-like opens.

The regression test opens two scipy-backed datasets from the same in-memory
NetCDF payload and verifies that the first dataset can still be pickled and
unpickled.

Validation:

  • python -m pytest xarray/tests/test_backends.py -k "scipy and pickle"
  • python -m pytest xarray/tests/test_backends.py -k "scipy"
  • python -m ruff check xarray/backends/scipy_.py xarray/tests/test_backends.py
  • git diff --check

AI assistance:
I used ChatGPT/Codex to help inspect the issue and plan a small local patch. I reviewed the final diff and test results myself and understand the submitted changes.

@hansu650
Copy link
Copy Markdown
Author

Thanks for the CI feedback. I'm going to close this for now because I don't have time to follow up on the Mypy failure properly. Sorry for the noise.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2026.4.0 breaks pickling with backends.scipy_

1 participant