diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2013-12-20 12:09:20 +0100 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2013-12-20 12:09:20 +0100 |
commit | 2da2cd68e60a628780eacec310cfdec24731ebcd (patch) | |
tree | f2ac0c6f90eb4d2153c660bc7aeb6d0b63680400 | |
parent | 6aca4e0d891d7a13d9712d9f1f8b0006ae1a87d8 (diff) | |
download | pylint-2da2cd68e60a628780eacec310cfdec24731ebcd.tar.gz |
[py3] avoid some unclosed file warning
-rw-r--r-- | config.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,4 +1,4 @@ -# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE). +# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE). # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later @@ -16,6 +16,7 @@ * pylintrc * pylint.d (PYLINTHOME) """ +from __future__ import with_statement import pickle import os @@ -49,7 +50,8 @@ def load_results(base): """ data_file = get_pdata_path(base, 1) try: - return pickle.load(open(data_file)) + with open(data_file) as stream: + return pickle.load(stream) except: return {} @@ -67,7 +69,8 @@ def save_results(results, base): print >> sys.stderr, 'Unable to create directory %s' % PYLINT_HOME data_file = get_pdata_path(base, 1) try: - pickle.dump(results, open(data_file, _PICK_MOD)) + with open(data_file, _PICK_MOD) as stream: + pickle.dump(results, stream) except (IOError, OSError), ex: print >> sys.stderr, 'Unable to create file %s: %s' % (data_file, ex) |