Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hrnciar opened this issue Mar 23, 2023 · 3 comments
Closed

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

hrnciar opened this issue Mar 23, 2023 · 3 comments
Assignees
Labels
3.12 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@hrnciar
Copy link
Contributor

hrnciar commented Mar 23, 2023

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

@hrnciar hrnciar added the type-bug An unexpected behavior, bug, or error label Mar 23, 2023
@mdboom mdboom added stdlib Python modules in the Lib dir 3.12 only security fixes labels Mar 23, 2023
@arhadthedev
Copy link
Member

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

@mgorny
Copy link
Contributor

mgorny commented Oct 24, 2023

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

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Oct 24, 2023
@gpshead gpshead self-assigned this Oct 24, 2023
gpshead pushed a commit that referenced this issue Oct 24, 2023
#103565)

gh-102956: Fix returning of empty byte strings after seek in zipfile module. This was a regression in 3.12.0 due to a performance enhancement.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 24, 2023
…pfile … (pythonGH-103565)

(cherry picked from commit c73b0f3)

Co-authored-by: Jokimax <[email protected]>
pythongh-102956: Fix returning of empty byte strings after seek in zipfile module. This was a regression in 3.12.0 due to a performance enhancement.
gpshead pushed a commit that referenced this issue Oct 25, 2023
…ipfile … (GH-103565) (#111289)

gh-102956: Fix returning of empty byte strings after seek in zipfile … (GH-103565)
(cherry picked from commit c73b0f3)


gh-102956: Fix returning of empty byte strings after seek in zipfile module. This was a regression in 3.12.0 due to a performance enhancement.

Co-authored-by: Jokimax <[email protected]>
@gpshead
Copy link
Member

gpshead commented Oct 25, 2023

Thanks! 3.12.1 should include the fix.

@gpshead gpshead closed this as completed Oct 25, 2023
listout pushed a commit to listout/gentoo that referenced this issue Oct 28, 2023
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…pfile … (python#103565)

pythongh-102956: Fix returning of empty byte strings after seek in zipfile module. This was a regression in 3.12.0 due to a performance enhancement.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…pfile … (python#103565)

pythongh-102956: Fix returning of empty byte strings after seek in zipfile module. This was a regression in 3.12.0 due to a performance enhancement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

5 participants