diff options
author | Scott Maxwell <scott@codecobblers.com> | 2013-11-19 08:56:53 -0800 |
---|---|---|
committer | Scott Maxwell <scott@codecobblers.com> | 2013-11-19 08:56:53 -0800 |
commit | 2da5f1fb4565d1e6dc72672f640dac44b122d235 (patch) | |
tree | 341373c292485f1417933551cc5c425d17fbbd44 /paramiko/primes.py | |
parent | 7471515fffd2315f7330c5e1dd42f353982ded6c (diff) | |
download | paramiko-2da5f1fb4565d1e6dc72672f640dac44b122d235.tar.gz |
Use 'with' for opening most file and SFTPFIle objects
Diffstat (limited to 'paramiko/primes.py')
-rw-r--r-- | paramiko/primes.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/paramiko/primes.py b/paramiko/primes.py index 13ec52d0..d10a15fb 100644 --- a/paramiko/primes.py +++ b/paramiko/primes.py @@ -113,8 +113,7 @@ class ModulusPack (object): @raise IOError: passed from any file operations that fail. """ self.pack = {} - f = open(filename, 'r') - try: + with open(filename, 'r') as f: for line in f: line = line.strip() if (len(line) == 0) or (line[0] == '#'): @@ -123,8 +122,6 @@ class ModulusPack (object): self._parse_modulus(line) except: continue - finally: - f.close() def get_modulus(self, min, prefer, max): bitsizes = sorted(self.pack.keys()) |