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

Can't pdb a setup() call in Windows cmd.exe #433

Open
ghost opened this issue Sep 9, 2015 · 1 comment
Open

Can't pdb a setup() call in Windows cmd.exe #433

ghost opened this issue Sep 9, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 9, 2015

Originally reported by: embray (Bitbucket: embray, GitHub: embray)


I ran across this while trying to run

$ python3.4 -m pdb setup.py build_ext

on Windows, in a standard cmd.exe prompt, while trying to debug an unrelated issue.

This results in a traceback stemming from Pdb ending with:

ValueError: underlying buffer has been detached

the full traceback isn't really important. This traces back to https://bitbucket.org/tarek/distribute/issues/311 -- because the original sys.stdout's raw buffer is detached, Pdb breaks. https://bitbucket.org/tarek/distribute/issues/334 added a partial workaround, but it's acknowledge there that there may be corner cases not covered. This is one such corner case.

One workaround is to manually edit the distutils/setuptools/etc. source code and add a pdb.set_trace() closer to the code you wish to debug (so that PDB is not invoked until after this sys.stdout switcheroo).

Some other possibilities might be to monkeypatch distutils.dist to replace the print() function (this all only applies to Python 3 anyways IIUC) or alternatively pdb can be monkeypatched. The code the messes with sys.stdout could be rewritten as a context manager that handles this.

It's probably not worth it though since this is indeed a narrow corner case. But if you would accept such a patch I'll think about writing it. In the meantime just thought I'd document the issue.


@ghost
Copy link
Author

ghost commented Sep 10, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


I've run into this issue myself. Thanks for writing up the details and your research. I'd like a better experience, so if you're interested in pursuing a patch, I'd be eager to see it.

@ghost ghost added minor bug labels Mar 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants