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 — I think `key` is a string and `read()` expects an int. Should this be just · Issue #29282 · numpy/numpy

I think key is a string and read() expects an int. Should this be just #29282

New issue
Copy link
New issue
Copy link
Closed
#29412
#29313
Closed
I think key is a string and read() expects an int. Should this be just#29282
#29412
#29313
Copy link
Milestone
2.3.2 release

Description

@seberg
seberg
opened on Jun 27, 2025
Issue body actions

I think key is a string and read() expects an int. Should this be just

                    return bytes.read()

Originally posted by @DWesl in #29098 (comment)

Activity

  1. seberg
    added this to the 2.3.2 release milestone on Jun 27, 2025
  2. DWesl commented on Jun 28, 2025

    @DWesl
    DWesl
    on Jun 28, 2025
    Contributor
    More actions

    Referring to

    numpy/numpy/lib/_npyio_impl.py

    Line 264 in 0f18e7c

    return bytes.read(key)

    It looks like this code path is for non-.npy files in the .npz, which savez and savez_compressed don't create. Most likely this would mean someone created an npz then added some metadata manually, then wanted to get the metadata back out without opening a separate object. Creating a test would need to go through the zipfile interface directly.

    Reacted by Sebastian Berg
  3. DWesl commented on Jul 4, 2025

    @DWesl
    DWesl
    on Jul 4, 2025
    Contributor
    More actions

    I tried adding a test based on that hypothesis in #29313, and it passed, so either it works as-is for some reason or that still doesn't touch that code-path.

  4. seberg commented on Jul 4, 2025

    @seberg
    seberg
    on Jul 4, 2025
    MemberAuthor
    More actions

    Hadn't looked at it much, just parsed it as "yeah looks like an accidental change".

    This returns the contents of a file included in the .npz verbatim. I.e. a zip file that contains not just .npy's, but also some arbitrary file and we just return it's bytes.
    It seems a bit strange, because I don't think we allow writing such an .npz easily.

    I suppose that makes it possible to use the loader to read arbitrary zip files and magically return arrays when it happens to be an .npy.

    Not don't think I like the behavior (I think I might prefer if it was folded into a method rather than __getitem__ if needed) so that __getitem__ can be relied on to return an array, but that is the more modern, stricter typing ideals speaking, maybe...

    EDIT: Sorry, that was what you said of course... the test just wasn't running...

  5. seberg
    closed this as completedin #29313on Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • 2.3.2 release

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.