mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
gh-80744: do not read .pdbrc twice when cwd == $home (#136816)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / iOS (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/check-c-api-docs (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / iOS (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/check-c-api-docs (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
This commit is contained in:
parent
b8d3fddba6
commit
09044dd42b
3 changed files with 30 additions and 7 deletions
19
Lib/pdb.py
19
Lib/pdb.py
|
|
@ -391,17 +391,22 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
|||
# Read ~/.pdbrc and ./.pdbrc
|
||||
self.rcLines = []
|
||||
if readrc:
|
||||
home_rcfile = os.path.expanduser("~/.pdbrc")
|
||||
local_rcfile = os.path.abspath(".pdbrc")
|
||||
|
||||
try:
|
||||
with open(os.path.expanduser('~/.pdbrc'), encoding='utf-8') as rcFile:
|
||||
self.rcLines.extend(rcFile)
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
with open(".pdbrc", encoding='utf-8') as rcFile:
|
||||
self.rcLines.extend(rcFile)
|
||||
with open(home_rcfile, encoding='utf-8') as rcfile:
|
||||
self.rcLines.extend(rcfile)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if local_rcfile != home_rcfile:
|
||||
try:
|
||||
with open(local_rcfile, encoding='utf-8') as rcfile:
|
||||
self.rcLines.extend(rcfile)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
self.commands = {} # associates a command list to breakpoint numbers
|
||||
self.commands_defining = False # True while in the process of defining
|
||||
# a command list
|
||||
|
|
|
|||
|
|
@ -4093,6 +4093,23 @@ def bœr():
|
|||
f.write("invalid")
|
||||
self.assertEqual(pdb.Pdb().rcLines[0], "invalid")
|
||||
|
||||
def test_readrc_current_dir(self):
|
||||
with os_helper.temp_cwd() as cwd:
|
||||
rc_path = os.path.join(cwd, ".pdbrc")
|
||||
with open(rc_path, "w") as f:
|
||||
f.write("invalid")
|
||||
self.assertEqual(pdb.Pdb().rcLines[-1], "invalid")
|
||||
|
||||
def test_readrc_cwd_is_home(self):
|
||||
with os_helper.EnvironmentVarGuard() as env:
|
||||
env.unset("HOME")
|
||||
with os_helper.temp_cwd() as cwd, patch("os.path.expanduser"):
|
||||
rc_path = os.path.join(cwd, ".pdbrc")
|
||||
os.path.expanduser.return_value = rc_path
|
||||
with open(rc_path, "w") as f:
|
||||
f.write("invalid")
|
||||
self.assertEqual(pdb.Pdb().rcLines, ["invalid"])
|
||||
|
||||
def test_header(self):
|
||||
stdout = StringIO()
|
||||
header = 'Nobody expects... blah, blah, blah'
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix issue where ``pdb`` would read a ``.pdbrc`` twice if launched from the home directory
|
||||
Loading…
Add table
Add a link
Reference in a new issue