Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix python3.11 _ModuleTarget _ScriptTarget compatibility #520

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix python3.11 _ModuleTarget _ScriptTarget compatibility
  • Loading branch information
Valentin Iovene committed May 26, 2023
commit 43110468db056744c3215c7737bdb87b338bf9f7
16 changes: 15 additions & 1 deletion src/pdbpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def rebind_globals(func, newglobals):
_newfunc(func.func, newglobals), *func.args, **func.keywords
)

# Python 3.11
_pdb = __import__("pdb", fromlist=("_ModuleTarget", "_ScriptTarget"))
if isinstance(func, (_pdb._ModuleTarget, _pdb._ScriptTarget)):
return func

raise ValueError("cannot handle func {!r}".format(func))


Expand Down Expand Up @@ -2199,7 +2204,16 @@ def _remove_bdb_context(evalue):
_usage = pdb._usage

# copy some functions from pdb.py, but rebind the global dictionary
for name in 'run runeval runctx runcall main set_trace'.split():
for name in (
"run",
"runeval",
"runctx",
"runcall",
"main",
"set_trace",
"_ModuleTarget", # Python 3.11
"_ScriptTarget", # Python 3.11
):
func = getattr(pdb, name)
globals()[name] = rebind_globals(func, globals())
del name, func
Expand Down