2011-08-10 23:34:21 Greg Stein napisaĆ(a): > On Wed, Aug 10, 2011 at 16:17, <[email protected]> wrote: > > Author: hwright > > Date: Wed Aug 10 20:17:55 2011 > > New Revision: 1156347 > > > > URL: http://svn.apache.org/viewvc?rev=1156347&view=rev > > Log: > > On the fs-py branch: > > Explicitly close files in the Python module, per the Python docs. > > > > * subversion/python/svn/fs.py > > (FS.set_uuid, FS._open_fs): Explicitly close a file, rather than just > > letting it go out of scope. > > Hunh? Which docs? This only makes sense if you're running in alternate > Python environments like Jython. CPython closes the file when the > refcount his zero.
CPython >=3.2 detects files (and sockets) not closed explicitly or via
__exit__() and can print ResourceWarnings.
$ python2.7 -Wd -c 'open("/dev/null")'
$ python3.1 -Wd -c 'open("/dev/null")'
$ python3.2 -Wd -c 'open("/dev/null")'
-c:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null'
mode='r' encoding='UTF-8'>
--
Arfrever Frehtes Taifersar Arahesis
signature.asc
Description: This is a digitally signed message part.

