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

Conversation

tgy
Copy link

@tgy tgy commented May 26, 2023

python -m pdb myscript.py currently does not work under Python 3.11

This fixes it, based on changes proposed by @blueyed in #516

@petobens
Copy link
Contributor

Hi @tgy, with this commit I'm getting the following when running python -m pdb -cc foo.py:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/pedro/.local/lib/python3.11/site-packages/_pdbpp_path_hack/pdb.py", line 17, in <module>
    exec(compile(f.read(), pdb_path, 'exec'))
  File "/home/pedro/.local/lib/python3.11/site-packages/pdbpp.py", line 2222, in <module>
    globals()[name] = rebind_globals(func, globals())
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pedro/.local/lib/python3.11/site-packages/pdbpp.py", line 135, in rebind_globals
    _pdb = __import__("pdb", fromlist=("_ModuleTarget", "_ScriptTargetu"))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pedro/.local/lib/python3.11/site-packages/_pdbpp_path_hack/pdb.py", line 17, in <module>
    exec(compile(f.read(), pdb_path, 'exec'))
  File "/home/pedro/.local/lib/python3.11/site-packages/pdbpp.py", line 2222, in <module>
    globals()[name] = rebind_globals(func, globals())
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pedro/.local/lib/python3.11/site-packages/pdbpp.py", line 143, in rebind_globals
    raise ValueError("cannot handle func {!r}".format(func))
ValueError: cannot handle func <class 'pdb._ModuleTarget'>

src/pdbpp.py Outdated Show resolved Hide resolved
@tgy
Copy link
Author

tgy commented May 26, 2023

It seems that the type comparison is not working. So I changed the code to use func.__name__ instead.

I'm seeing that pdbpp keeps restarting the program indefinitely. Seems weird. Can you guys debug on your side?

@petobens
Copy link
Contributor

I'm seeing the same error as before.. I'll try to have a harder look but dunno what's going on..

@petobens
Copy link
Contributor

@blueyed any pointers on this one? It would be really nice (even necessary) to get this working again on 3.11.. Thanks in advance.

bretello added a commit to bretello/pdbpp that referenced this pull request Jul 7, 2023
based on the changes in proposed in pdbpp#516 and pdbpp#520

fixes pdbpp#516
bretello added a commit to bretello/pdbpp that referenced this pull request Jul 7, 2023
based on the changes in proposed in pdbpp#516 and pdbpp#520

fixes pdbpp#516
bretello added a commit to bretello/pdbpp that referenced this pull request Jul 7, 2023
based on the changes in proposed in pdbpp#516 and pdbpp#520

fixes pdbpp#516
@blueyed
Copy link
Collaborator

blueyed commented Oct 18, 2023

Closing in favor of #521.

@blueyed blueyed closed this Oct 18, 2023
@blueyed blueyed reopened this Oct 18, 2023
@blueyed
Copy link
Collaborator

blueyed commented Oct 18, 2023

(but let's run CI on it still)

@blueyed blueyed closed this Oct 18, 2023
bretello added a commit to bretello/pdbpp that referenced this pull request Oct 29, 2023
based on the changes in proposed in pdbpp#516 and pdbpp#520

fixes pdbpp#516
bretello added a commit to bretello/pdbpp that referenced this pull request Oct 29, 2023
based on the changes in proposed in pdbpp#516 and pdbpp#520

fixes pdbpp#516
bretello added a commit to bretello/pdbpp that referenced this pull request Nov 7, 2023
based on the changes in proposed in pdbpp#516 and pdbpp#520

fixes pdbpp#516
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants