summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-09-03 19:52:03 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-09-03 19:52:03 (GMT)
commit7dde792e62c8adeaf5d633dc89e18d16067add8e (patch)
tree41852c7a810c87d0a804d19f7ba6bc4266b1d66c /Lib/pdb.py
parent24e561ae0473ad6f46709e38ed8ebc97d89fc55e (diff)
downloadcpython-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-xLib/pdb.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 3362ea1..83ff585 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -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