-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
'Pdb' object has no attribute 'botframe' #88627
Comments
While doing some debugging on bpo-44459 using Python 3.10b3, I was using Pdb and after troubleshooting an exception and hitting 'q' to quit, I saw the following:
I'd not seen this error before, so I suspect there may be a regression in 3.10. I haven't investigated further, but I wanted to register this possible issue. |
I encountered the same error on Python 3.9. |
I can replicate the issue with this command: |
I was unable to replicate the issue with a foo.py containing only |
The difference between Jason's two test cases is which stage of Pdb._runmodule() fails. In the case of In the case of |
However, if we just try to initialize self.botframe to None in __init__, then 'quit' doesn't work anymore, so something else needs to be done about cleanup when import fails at that stage. |
The cleanup issue was in the except: clause of the main loop: if the user does quit() during the pdb.interaction() call upon an unhandled exception ("the post mortem debugger"), then this quit request is ignored and the program just restarts. The attached patch fixes this by checking for quit requests after the port-mortem debugger returns. |
Thanks Irit. Reviewing now... |
I've close PR26937 since we're not going for that. The test from it might still be useful, so I'm copying it here: def test_package_without_a_main(self):
pkg_name = 't_pkg'
module_name = 't_main'
os_helper.rmtree(pkg_name)
modpath = pkg_name + '/' + module_name
os.makedirs(modpath)
with open(modpath + '/__init__.py', 'w') as f:
pass
self.addCleanup(os_helper.rmtree, pkg_name)
stdout, stderr = self._run_pdb(['-m', modpath.replace('/', '.')], "")
self.assertIn(
"'t_pkg.t_main' is a package and cannot be directly executed",
stdout) |
This issue is solved. Thanks Irit for taking the time to investigate the issue and do the hard part of developing a test. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: