Skip to content
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

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

Open
hrnciar opened this issue Mar 23, 2023 · 1 comment
Open
Labels
3.12 bugs and 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 bugs and security fixes labels Mar 23, 2023
@arhadthedev
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
Status: No status
Development

No branches or pull requests

3 participants