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 — Add `seekable` method for `mmap.mmap` · Issue #111835 · python/cpython

Add seekable method for mmap.mmap #111835

New issue
Copy link
New issue
Copy link
Closed
Closed
Add seekable method for mmap.mmap#111835
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@technillogue
technillogue
opened on Nov 8, 2023
Issue body actions

Bug report

Bug description:

mmap.mmap has a seek() method, but no seekable() method. Because of this, it cannot be used an argument for ZipFile, which requires a file-like object with seekable. A small patch is enough to fix this

class SeekableMmap(mmap.mmap):
    def seekable(self):
        return True

Now SeekableMmap can be passed to ZipFile without issue. It's easy to fix, but I can't think of any reasons why mmap shouldn't have a seekable method.

CPython versions tested on:

3.8, 3.11

Operating systems tested on:

Linux

Linked PRs

  • gh-111835: Add seekable method to mmap.mmap #111852
  • pythongh-111835: Add seekable method to mmap.mmap #111865

Activity

  1. technillogue
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 8, 2023
  2. Eclips4
    added
    type-featureA feature request or enhancementA feature request or enhancement
    and removed
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 8, 2023
  3. Eclips4
    changed the title [-]mmap doesn't have a seekable method[/-] [+]Add `seekable` method for `mmap.mmap`[/+] on Nov 8, 2023
  4. corona10
    added 4 commits that reference this issue on Nov 8, 2023

    pythongh-111835: Add seekable method to mmap.mmap

    4bac18a

    pythongh-111835: Add seekable method to mmap.mmap

    d699f98

    Merge branch 'main' into pythongh-111835

    8a12113

    Merge remote-tracking branch 'origin/pythongh-111835' into pythongh-1…

    1b8d6cc
  5. serhiy-storchaka commented on Nov 8, 2023

    @serhiy-storchaka
    serhiy-storchaka
    on Nov 8, 2023
    Member
    More actions

    mmap.seek() returns None. The seek() method of other file-like objects return the new file position. Would not it cause issues?

  6. technillogue
    added a commit that references this issue on Nov 8, 2023

    pythongh-111835: Add seekable method to mmap.mmap

    f38cc90
  7. technillogue commented on Nov 8, 2023

    @technillogue
    technillogue
    on Nov 8, 2023
    ContributorAuthor
    More actions

    I also opened a PR #111865 for this, I just took a while between pushing the code and opening the PR.

  8. corona10 commented on Nov 8, 2023

    @corona10
    corona10
    on Nov 8, 2023
    Member
    More actions

    mmap.seek() returns None. The seek() method of other file-like objects return the new file position. Would not it cause issues?

    Yeah, in that case, we can make a seek() method to return where value. It will break the user's code actually?
    In my naive idea, people cannot do something with None value.

  9. corona10
    added a commit that references this issue on Nov 9, 2023

    gh-111835: Add seekable method to mmap.mmap (gh-111852)

    6046aec
  10. corona10 commented on Nov 9, 2023

    @corona10
    corona10
    on Nov 9, 2023
    Member
    More actions

    @technillogue

    #111852 is landed, this feature will be available from CPython 3.13
    Thanks for the suggestion!

    @serhiy-storchaka @vstinner
    Thanks for your valuable feedback and reviews!

    Reacted by technillogue
  11. corona10
    closed this as completedon Nov 9, 2023
  12. aisk
    added a commit that references this issue on Feb 11, 2024

    pythongh-111835: Add seekable method to mmap.mmap (pythongh-111852)

    3706873
  13. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-111835: Add seekable method to mmap.mmap (pythongh-111852)

    1ffbd09
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

    type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.