[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1156347 - /subversion/branches/fs-py/subversion/python/svn/fs.py

From: Arfrever Frehtes Taifersar Arahesis <arfrever.fta_at_gmail.com>
Date: Thu, 11 Aug 2011 00:37:42 +0200

2011-08-10 23:34:21 Greg Stein napisaƂ(a):
> On Wed, Aug 10, 2011 at 16:17, <hwright_at_apache.org> 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

Received on 2011-08-11 00:38:32 CEST

This is an archived mail posted to the Subversion Dev mailing list.