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

ValueError on ephemeral zipfile after exception #106763

Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@jaraco

Description

@jaraco

Consider this repro:

 draft @ cat zip-tb.txt>>> import zipfile>>> import io>>> zf = zipfile.ZipFile(io.BytesIO(), 'w')>>> zf.foo  # doctest: +ELLIPSISTraceback (most recent call last):...AttributeError: ... draft @ py -3.12 -m doctest zip-tb.txtException ignored in: <function ZipFile.__del__ at 0x100f36b60>Traceback (most recent call last):  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/zipfile/__init__.py", line 1916, in __del__    self.close()  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/zipfile/__init__.py", line 1933, in close    self.fp.seek(self.start_dir)ValueError: I/O operation on closed file.

The test runs fine, but triggers aValueErroratexit.

The issue only arises if the last expression in the doctest triggered a traceback and the zipfile was present in the traceback. Changingzf.foo toio.foo or adding>>> pass bypasses the error.

I suspect there's a flaw in doctest that leaves resources unclosed if the last expression is handling a traceback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp