Skip to content

Regression in zipfile, read1(-1) after seek() returns empty byte string #102956

Closed

Description

@hrnciar

Bug report

When debugging a test failure in https://pypi.org/project/fs/ I found a regression in zipfile, read1(-1) after seek() returns empty byte string instead of substring. I've bisected it into this commit 330f1d5.

Reproducer:

import zipfile

# First, create the zip:
#   echo 'Hello, World' > hello.txt
#   zip hello.zip hello.txt

with zipfile.ZipFile('hello.zip') as myzip:
    with myzip.open('hello.txt') as myfile:
        print(myfile.read(5))
        print(myfile.seek(2, 1))
        print(myfile.read1(-1))

Expected output (3.11.2):

❯ python3.11 reproduce.py
b'Hello'
7
b'World\n'

Actual output (3.12.0a6):

❯ python3.12 reproduce.py
b'Hello'
7
b''

Your environment

  • CPython versions tested on: main
  • Operating system and architecture: Fedora 37, x86_64

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    3.12only security fixes
    on Mar 23, 2023
  2. arhadthedev commented on Mar 23, 2023

    @arhadthedev
    Member

    @serhiy-storchaka, @Yhg1s, @gpshead (as zipfile experts)

  3. added 2 commits that reference this issue on Apr 15, 2023
  4. mgorny commented on Oct 24, 2023

    @mgorny
    Contributor

    Ping. This is still breaking fs, and there's a patch waiting for review since April.

  5. self-assigned this
    on Oct 24, 2023
  6. added a commit that references this issue on Oct 24, 2023
  7. added a commit that references this issue on Oct 24, 2023
  8. added a commit that references this issue on Oct 25, 2023
  9. gpshead commented on Oct 25, 2023

    @gpshead
    Member

    Thanks! 3.12.1 should include the fix.

  10. added a commit that references this issue on Feb 11, 2024
  11. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions