[New-bugs-announce] [issue23865] Fix possible leaks in close methods

Serhiy Storchaka report at bugs.python.org
Sat Apr 4 13:13:00 CEST 2015

New submission from Serhiy Storchaka:

Proposed patch fixes two related issues in a number of modules.

1. close() methods sometimes release multiple resources. Every closing operation can fail, but it shouldn't prevent releasing other resources. See for example issue21802.

2. close() should be idempotent. I.e. calling close() second times shouldn't have any effect. Even if close() failed, repeated call of close() (usually in __exit__(), in __del__(), or in finally block) shouldn't raise an exception.

Many close() methods already satisfy these conditions, but not all.

components: Library (Lib)
files: close.patch
keywords: patch
messages: 240063
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Fix possible leaks in close methods
type: resource usage
versions: Python 2.7, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file38829/close.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list