Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove reference cycle when writing tarfiles #115256

Closed
Labels
type-featureA feature request or enhancement
@pan324

Description

@pan324

Feature or enhancement

Proposal:

The following code keeps a file handle for eternity and evengc.collect does not help.

>>>importtarfile>>>tarfile.TarFile("archive.tar.gz","w").add("somefile.py")

The culprit is a line that itself says that it is not needed. Indeed, it is never used anywhere.https://github.com/python/cpython/blob/main/Lib/tarfile.py#L2033

Now the example might be a rather bad style, but even a typical use case where a TarFile variable is defined and closed afterwards will also keep some stuff in memory untilgc.collect happens due to this line. Removing the line also adds a ResourceWarning to the bad style example which currently does not appear.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp