mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-95913: make the new internal classes pdb.ModuleTarget/ScriptTarget private (GH-96053)
This commit is contained in:
parent
4a6fa89465
commit
1a720c6003
2 changed files with 5 additions and 5 deletions
|
@ -131,7 +131,7 @@ class _rstr(str):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class ScriptTarget(str):
|
class _ScriptTarget(str):
|
||||||
def __new__(cls, val):
|
def __new__(cls, val):
|
||||||
# Mutate self to be the "real path".
|
# Mutate self to be the "real path".
|
||||||
res = super().__new__(cls, os.path.realpath(val))
|
res = super().__new__(cls, os.path.realpath(val))
|
||||||
|
@ -167,7 +167,7 @@ class ScriptTarget(str):
|
||||||
return f"exec(compile({fp.read()!r}, {self!r}, 'exec'))"
|
return f"exec(compile({fp.read()!r}, {self!r}, 'exec'))"
|
||||||
|
|
||||||
|
|
||||||
class ModuleTarget(str):
|
class _ModuleTarget(str):
|
||||||
def check(self):
|
def check(self):
|
||||||
try:
|
try:
|
||||||
self._details
|
self._details
|
||||||
|
@ -1625,7 +1625,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
return fullname
|
return fullname
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _run(self, target: Union[ModuleTarget, ScriptTarget]):
|
def _run(self, target: Union[_ModuleTarget, _ScriptTarget]):
|
||||||
# When bdb sets tracing, a number of call and line events happen
|
# When bdb sets tracing, a number of call and line events happen
|
||||||
# BEFORE debugger even reaches user's code (and the exact sequence of
|
# BEFORE debugger even reaches user's code (and the exact sequence of
|
||||||
# events depends on python version). Take special measures to
|
# events depends on python version). Take special measures to
|
||||||
|
@ -1789,7 +1789,7 @@ def main():
|
||||||
commands = [optarg for opt, optarg in opts if opt in ['-c', '--command']]
|
commands = [optarg for opt, optarg in opts if opt in ['-c', '--command']]
|
||||||
|
|
||||||
module_indicated = any(opt in ['-m'] for opt, optarg in opts)
|
module_indicated = any(opt in ['-m'] for opt, optarg in opts)
|
||||||
cls = ModuleTarget if module_indicated else ScriptTarget
|
cls = _ModuleTarget if module_indicated else _ScriptTarget
|
||||||
target = cls(args[0])
|
target = cls(args[0])
|
||||||
|
|
||||||
target.check()
|
target.check()
|
||||||
|
|
|
@ -229,7 +229,7 @@ class PyclbrTest(TestCase):
|
||||||
cm(
|
cm(
|
||||||
'pdb',
|
'pdb',
|
||||||
# pyclbr does not handle elegantly `typing` or properties
|
# pyclbr does not handle elegantly `typing` or properties
|
||||||
ignore=('Union', 'ModuleTarget', 'ScriptTarget'),
|
ignore=('Union', '_ModuleTarget', '_ScriptTarget'),
|
||||||
)
|
)
|
||||||
cm('pydoc', ignore=('input', 'output',)) # properties
|
cm('pydoc', ignore=('input', 'output',)) # properties
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue