]> granicus.if.org Git - python/commit
#17616: Improve context manager tests, fix bugs in close method and mode docs.
authorR David Murray <rdmurray@bitdance.com>
Thu, 1 Aug 2013 00:48:26 +0000 (20:48 -0400)
committerR David Murray <rdmurray@bitdance.com>
Thu, 1 Aug 2013 00:48:26 +0000 (20:48 -0400)
commit536ffe161c014f3646cbf52bc527f2ba9ebd6478
treefc1491b81c3db517bad24d0ec425b666cf37a426
parentabe639f1150a770b2435417330c1c2a5a2e239ab
#17616: Improve context manager tests, fix bugs in close method and mode docs.

'mode' docs fix: the file must always be opened in binary in Python3.

Bug in Wave_write.close: when the close method calls the check that the header
exists and it raises an error, the _file attribute never gets set to None, so
the next close tries to close the file again and we get an ignored traceback
in the __del__ method.  The fix is to set _file to None in a finally clause.
This represents a behavior change...in theory a program could be checking for
the error on close and then doing a recovery action on the still open file and
closing it again.  But this change will only go into 3.4, so I think that
behavior change is acceptable given that it would be pretty weird and unlikely
logic to begin with.
Doc/library/wave.rst
Lib/test/test_wave.py
Lib/wave.py