GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DEP: Undo deprecation for ``np.dtype()`` signature used by old pickles by seberg · Pull Request #31177 · numpy/numpy

Conversation

@seberg

@seberg seberg commented Apr 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Some (very) old pickles pass align=0, copy=1 as integers rather than bools.
This just assumes no user will really do that, and allows it.

It may be possible to also use copyreg to work around it, but since it is a rather specific signature this seems easier/just as well.

(No special tooling)

Closes gh-30786

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

halberstam-2 and gdementen reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@jorenham jorenham added the 07 - Deprecation label Apr 7, 2026
@seberg
DEP: Undo deprecation for np.dtype() signature used by old pickles
86662bf
Some (very) old pickles pass align=0, copy=1 as integers rather than
bools.
This just assumes no user will really do that, and allows it.

It may be possible to also use `copyreg` to work around it, but
since it is a rather specific signature this seems easier/just as
well.
@seberg
seberg force-pushed the no-deprecation-old-pickles branch from c2a2b90 to 86662bf Compare April 7, 2026 13:58
@seberg seberg added this to the 2.4.5 release milestone Apr 9, 2026
@seberg seberg added the 09 - Backport-Candidate PRs tagged should be backported label Apr 9, 2026
@ngoldbaum

ngoldbaum commented Apr 9, 2026

Copy link
Copy Markdown
Member

This fixes #30786, right? Ping @flying-sheep.

flying-sheep reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg

seberg commented Apr 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Yeah, I just didn't check if the long discussion on docs warranted leaving it open.

EDIT: but probably just as well to do.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ngoldbaum
ngoldbaum reviewed Apr 9, 2026
View reviewed changes

@ngoldbaum ngoldbaum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Storing old test data in a pickle file seems like a reasonable use-case so I'm happy to un-deprecate this. I spotted some incorrect C API uses below (with my own eyes, no Claude this time 😜).

It also maybe needs a release note? Kinda on the bubble. It is changing how the deprecations works a little though so that seems worth mentioning.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread numpy/_core/src/multiarray/descriptor.c Outdated
// Some old pickles use 0, 1 exactly, assume no user passes it
// (It may also be possible to use `copyreg` instead.)
PyLong_CheckExact(oalign) && PyLong_AsLong(oalign) == 0 &&
ocopy != NULL && PyLong_CheckExact(ocopy) && PyLong_AsLong(ocopy) == 1)) {

@ngoldbaum ngoldbaum Apr 9, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

PyLong_AsLong can fail and set OverflowError: https://docs.python.org/3/c-api/long.html#c.PyLong_AsLong. Ditto for all the other PyLong_As functions. It also looks like PyLong_AsLong is soft-deprecated - maybe use PyLong_AsInt instead?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seberg seberg Apr 9, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ack... yeah, annoying to add error handling here, but clearly needed...

PyLong_AsLong isn't soft depreated of course, PyLong_AS_LONG is.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seberg seberg Apr 9, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Well, I pushed a pretty annoying fix (annoying, because of how the control flow is).

I don't think this can ever fail, so I just made it a critical error, but I don't like baking this in when it isn't guaranteed in the C-API docs.

(The logic is really strange, because if it fails res == -1 the if branch is taken, tested locally by removing the PyLong_CheckExact which makes it possible to fail them)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seberg

seberg commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

I dunno, I was about to amend the 2.4.0 release notes to add a note that this corner case affecting pickles was solved in 2.4.5. But it feels a bit weird also?

OTOH, I don't think a release note in 2.5 seems helpful. This eases a pain in 2.4-2.4.4 (2.4.5 should get this as a backport, I think), so the only interesting point would be where you actually run into the pickle loading failure...

I'll add another comment to the original PR, I think that is the most likely place for someone actually to find the info...

gdementen reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg
Refine int checks (a bit annoyingly).
1edf7b6
@seberg
seberg force-pushed the no-deprecation-old-pickles branch from 0c35300 to 1edf7b6 Compare April 9, 2026 19:28
ngoldbaum
ngoldbaum approved these changes Apr 9, 2026
View reviewed changes
@gdementen

gdementen commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

@seberg Thanks a lot for your work

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gdementen gdementen mentioned this pull request Apr 10, 2026
DEP: Give a visible warning when align= to dtype is a non-bool #29301
Merged
@charris
charris merged commit bf18717 into numpy:main Apr 10, 2026
84 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@charris

charris commented Apr 10, 2026

Copy link
Copy Markdown
Member

Thanks Sebastian.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg
seberg deleted the no-deprecation-old-pickles branch April 10, 2026 12:10
@charris charris mentioned this pull request Apr 11, 2026
DEP: Undo deprecation for np.dtype() signature used by old pickles (#31177) #31211
Merged
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Apr 11, 2026
charris added a commit that referenced this pull request Apr 11, 2026
@charris
Merge pull request #31211 from charris/backport-31177
b22a613
DEP: Undo deprecation for np.dtype() signature used by old pickles (#31177)
@thehrh thehrh mentioned this pull request Apr 22, 2026
NumPy 2.4 deprecation warnings when unpickling: "dtype(): align should be passed as Python or NumPy boolean but got align=0" icecube/pisa#931
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ngoldbaum ngoldbaum ngoldbaum approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

07 - Deprecation

Projects

None yet

Milestone

2.4.5 release

Development

Successfully merging this pull request may close these issues.

DOC: np.save{,z} does not make clear that it’s not suited for longterm storage

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@seberg @ngoldbaum @gdementen @charris @jorenham
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.