diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-09-03 19:52:03 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-09-03 19:52:03 (GMT) |
commit | 7dde792e62c8adeaf5d633dc89e18d16067add8e (patch) | |
tree | 41852c7a810c87d0a804d19f7ba6bc4266b1d66c /Lib/pdb.py | |
parent | 24e561ae0473ad6f46709e38ed8ebc97d89fc55e (diff) | |
download | cpython-7dde792e62c8adeaf5d633dc89e18d16067add8e.zip cpython-7dde792e62c8adeaf5d633dc89e18d16067add8e.tar.gz cpython-7dde792e62c8adeaf5d633dc89e18d16067add8e.tar.bz2 |
Use a context manager for some file objects.
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-x | Lib/pdb.py | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -155,21 +155,15 @@ class Pdb(bdb.Bdb, cmd.Cmd): if 'HOME' in os.environ: envHome = os.environ['HOME'] try: - rcFile = open(os.path.join(envHome, ".pdbrc")) + with open(os.path.join(envHome, ".pdbrc")) as rcFile: + self.rcLines.extend(rcFile) except IOError: pass - else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() try: - rcFile = open(".pdbrc") + with open(".pdbrc") as rcFile: + self.rcLines.extend(rcFile) except IOError: pass - else: - for line in rcFile.readlines(): - self.rcLines.append(line) - rcFile.close() self.commands = {} # associates a command list to breakpoint numbers self.commands_doprompt = {} # for each bp num, tells if the prompt |