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
pydoc reports misleading failure if target module raises an ImportError #49480
Comments
If pydoc is used to try to look up the documentation for a module which
However, if it is used to look up the documentation for a module which
This is somewhat misleading, since it suggests that there is no such
I'm sure the cause of this is the incautious handling of ImportError by |
I've written a patch. |
Thanks :) PEP-8 recommends spaces after commas in a list. Also, we should have a unit tests before we commit the fix. If you feel |
The same patch with whitespaces. Is it ok now? |
You are still missing a space between 'module' and 'named' ;) |
A new patch with an unit test and with whitespaces. |
Thanks. The unit tests don't pass, though, at least not when I apply Also consider the case where the import is 'import some.nested.module', Also I'd recommend renaming badimport_module.py pydoc_badimport.py so as |
Ok. |
by the way, I was not acquainted with this unit test thing... sorry |
No need to apologize, and thank you for taking the time to learn this For me your new test fails...and it isn't quite the one I had in mind. (This makes me wonder...is the existing behavior of pydoc optimal? With The test I had in mind would be a file pydoc_badimport2.py containing: import test.i_dont_exist.neither_do_i In that case, your patch will fail, because the error message will It's funny how these seemingly simple things turn out to be not quite so |
I didn't understand what you mean: what should be shown when pydoc tries |
It should generate: problem in pydoc_badimport2 - <type 'exceptions.ImportError'>: No If you'd like I can do the final fixup and apply the patch. I'm happy |
Thanks :) |
Take a look at the output: This is different from what you expected. How do we change this output? |
I'm sorry, I mistyped. That is the error message I was expecting (it's
then I think the tests would pass (but I haven't checked yet). |
I had lots of stuff to do lately, sorry it took me so long to answer. $ cat pydoc_badimport3.py
import this_doesnt_exist.pydoc_badimport3
$ pydoc pydoc_badimport3 I tested this possibility, and I found out that there is a bug in this |
I've uploaded a new version of the patch and test suite. I wanted a few I haven't come up with a fix for your last test case (yet?). I've |
OK, I finally had time to come back to this, and figured out what I |
I think this patch is ok. |
Here is an updated patch that cleans up the unit test (I wasn't |
Applied to 2.7 in r73529 and 2.6 in r73530. Leaving ticket open until I Thanks for your help, Lucas. |
Benjamin merged this to py3k/3.1 as part of r73623/r73625. |
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: