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

gh-133982: Run unclosed file test on all io implementations#134165

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 2 commits intopython:mainfromcmaloney:pyio_dealloc_warn2
May 21, 2025
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Rely on IOBase __del__ implementation in FileIO
The FileIO one now matches all the others, so can use IOBase. There wasa missing check on closing (self._fd must be valid), add that check
  • Loading branch information
@cmaloney
cmaloney committedMay 18, 2025
commit704bf460f2891d02f102238a6b27e3c1e7e40060
7 changes: 1 addition & 6 deletionsLib/_pyio.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1613,11 +1613,6 @@ def _dealloc_warn(self, source):
warnings.warn(f'unclosed file {source!r}', ResourceWarning,
stacklevel=2, source=self)

def __del__(self):
if self._fd >= 0 and self._closefd and not self.closed:
self._dealloc_warn(self)
self.close()

def __getstate__(self):
raise TypeError(f"cannot pickle {self.__class__.__name__!r} object")

Expand DownExpand Up@@ -1791,7 +1786,7 @@ def close(self):
if not self.closed:
self._stat_atopen = None
try:
if self._closefd:
if self._closefd and self._fd >= 0:
os.close(self._fd)
finally:
super().close()
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp