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

module zipfile issue on closing #85806

Closed
bastianebeling mannequin opened this issue Aug 26, 2020 · 4 comments
Closed

module zipfile issue on closing #85806

bastianebeling mannequin opened this issue Aug 26, 2020 · 4 comments
Labels
3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@bastianebeling
Copy link
Mannequin

bastianebeling mannequin commented Aug 26, 2020

BPO 41640
Nosy @jaraco, @tirkarthi
Superseder
  • bpo-40564: Using zipfile.Path with several files prematurely closes zip
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-08-29.12:59:33.470>
    created_at = <Date 2020-08-26.07:31:32.143>
    labels = ['3.8', 'type-bug', 'library']
    title = 'module zipfile issue on closing'
    updated_at = <Date 2020-08-29.12:59:33.468>
    user = 'https://bugs.python.org/bastianebeling'

    bugs.python.org fields:

    activity = <Date 2020-08-29.12:59:33.468>
    actor = 'xtreak'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-08-29.12:59:33.470>
    closer = 'xtreak'
    components = ['Library (Lib)']
    creation = <Date 2020-08-26.07:31:32.143>
    creator = 'bastian.ebeling'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41640
    keywords = []
    message_count = 4.0
    messages = ['375917', '375918', '375922', '376061']
    nosy_count = 3.0
    nosy_names = ['jaraco', 'xtreak', 'bastian.ebeling']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '40564'
    type = 'behavior'
    url = 'https://bugs.python.org/issue41640'
    versions = ['Python 3.8']

    @bastianebeling
    Copy link
    Mannequin Author

    bastianebeling mannequin commented Aug 26, 2020

    When trying to open an archive and read internal binary streams, for me it occurs, that the file-stream gets closed.
    As a code-Snippet:

    import zipfile
    srcfile=zipfile.ZipFile('file.zip')
    a=zipfile.Path(srcfile,"data1.bin").read_bytes()
    b=zipfile.Path(srcfile,"data2.bin").read_bytes()

    the second call results in the ValueError: seek of closed file

    A quick and dirty solution (as an idea) is to change close() for the _SharedFile to run self.close() instead of self._close(findeobj) in the end (somehow around line 772).

    Hopefully that helps

    @bastianebeling bastianebeling mannequin added 3.8 only security fixes type-bug An unexpected behavior, bug, or error labels Aug 26, 2020
    @tirkarthi
    Copy link
    Member

    This seems to be a duplicate of bpo-40564 . Can you please add the python version you are using?

    @bastianebeling
    Copy link
    Mannequin Author

    bastianebeling mannequin commented Aug 26, 2020

    My used python Version is
    Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
    Indead - this issue seems to be the same as 40564, but maybe my suggested solution is helpful?

    @bastianebeling bastianebeling mannequin added stdlib Python modules in the Lib dir labels Aug 26, 2020
    @tirkarthi
    Copy link
    Member

    Thanks, I am closing this in favor of bpo-40564. Jason has provided some possible approaches in bpo-40564 (msg375964) and would be helpful to follow the discussion there since it has more details.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant