mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Use a context manager for some file objects.
This commit is contained in:
parent
24e561ae04
commit
7dde792e62
4 changed files with 20 additions and 32 deletions
14
Lib/pdb.py
14
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue