From 1b9b4856c86f3895445d8bd57a7ab18fc5cc9b20 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 18 Aug 2022 06:39:16 -0700 Subject: [PATCH] [3.11] gh-95913: make the new internal classes pdb.ModuleTarget/ScriptTarget private (GH-96053) (#96063) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Lib/pdb.py | 8 ++++---- Lib/test/test_pyclbr.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/pdb.py b/Lib/pdb.py index 58bc720275a280..fe8ddd1abb1085 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -131,7 +131,7 @@ def __repr__(self): return self -class ScriptTarget(str): +class _ScriptTarget(str): def __new__(cls, val): # Mutate self to be the "real path". res = super().__new__(cls, os.path.realpath(val)) @@ -167,7 +167,7 @@ def code(self): return f"exec(compile({fp.read()!r}, {self!r}, 'exec'))" -class ModuleTarget(str): +class _ModuleTarget(str): def check(self): try: self._details @@ -1625,7 +1625,7 @@ def lookupmodule(self, filename): return fullname 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 # BEFORE debugger even reaches user's code (and the exact sequence of # events depends on python version). Take special measures to @@ -1750,7 +1750,7 @@ def main(): commands = [optarg for opt, optarg in opts if opt in ['-c', '--command']] 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.check() diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py index b2de4e8397d6ad..23453e340159db 100644 --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -229,7 +229,7 @@ def test_others(self): cm( 'pdb', # pyclbr does not handle elegantly `typing` or properties - ignore=('Union', 'ModuleTarget', 'ScriptTarget'), + ignore=('Union', '_ModuleTarget', '_ScriptTarget'), ) cm('pydoc', ignore=('input', 'output',)) # properties