summaryrefslogtreecommitdiff
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-09-03 19:52:03 +0000
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-09-03 19:52:03 +0000
commit7ec721e9c2f75f0c708475154ce42fea5860480d (patch)
tree8d3be9e63390237d30a6b6ec111949a83e08bf07 /Lib/pdb.py
parentd33b28d1ab8cc3f9c49d52bc1608a7e140fc55bf (diff)
downloadcpython-7ec721e9c2f75f0c708475154ce42fea5860480d.tar.gz
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 3362ea1e70..83ff585c61 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