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 generates invalid docs.python.org link for xml.etree.ElementTree and other modules #60688
Comments
Do this: pydoc2.7 xml.etree.ElementTree then click on the MODULE DOCS link, which is http://docs.python.org/library/xml.etree.ElementTree You're redirected to http://docs.python.org/2/library/xml.etree.ElementTree which is a 404 page. |
The redirect is not the problem. The page never existed. |
A working link is http://docs.python.org/2/library/xml.etree.elementtree.html or http://docs.python.org/2/library/xml.etree.elementtree (with no .html at the end). Looks like capitalization is causing a problem. Did these pydoc links ever work? Would it be possible to make them work? There's a limited number of standard library modules with names that contain capital letters. find /usr/lib/python2.7 -name dist-packages -prune -o -name '*[A-Z]*' | wc -l gives me 211 names, but this is an imprecise upper bound because it includes files like 'distutils/README' that aren't modules or packages. Can I do anything to help? |
A patch and test making sure that pydoc generates the right URIs for upper-case modules would help. |
Considering many existing Python installations out there would it be possible to fix this on the server side? I.e. lowercase the URL while redirecting? |
Adding a redirect should be easy, yes. |
I could try to create the patch for pydoc if you would like for me to. |
To display my ignorance, I have run the pydoc command listed in the original message but I can't actually see where it lists the url. Or even where it has a link. |
Near the top: Help on module xml.etree.ElementTree in xml.etree: NAME FILE MODULE DOCS DESCRIPTION |
Here is a working patch for python 2.7. all it does is lowercase the module name, but once I did that and clicked the link it worked correctly. |
Note: It doesn't change the actual module name. Just how it is represented in the link. |
Here is the patch for python 3.2. It implements the same fix that the 2.7 patch does. |
Sorry guys, I missed a place I needed to add the lower() fuction to the module.__name__. Here is a fixed patch for python2.7. |
Here are the python3.2 and python3.3 patches. Please let me know if there is anything I need to change on these. |
Is there anything else I can do for this? |
It would be nice to have unit tests for this change. Did you get an email from the review system? If not, follow the “review” link on the right of the list of files on this page. |
I don’t think these ones could be so easily fixed, but on my computer “pydoc” references:
|
Brett, any opposition to moving the doc about importlib submodules to separate files? |
No, I have no objections. |
Applied patch from sean.rodman. |
Applied patch from sean.rodman. |
This patch looks good to me. Note that the reason for the basedir change is that the test would fail if run from a build directory which hadn't been installed. An implication of this is that 'doc_loc' is None most of the time when the other tests are run, meaning that this new test is the only one that consistently tests the body of getdocloc. I think that method could use some more tests, but that is a separate issue. |
New changeset 64e7c8531131 by R David Murray in branch '3.5': New changeset 912b9aad0b45 by R David Murray in branch 'default': |
Thanks Sean and Kaushik. The final patch didn't apply to 2.7. If someone wants to port the patch I'll apply it, but I'm going to close the issue. |
It seems the test is broken on Windows: http://buildbot.python.org/all/builders/x86%20Windows7%203.5/builds/915/steps/test/logs/stdio Traceback (most recent call last):
File "D:\cygwin\home\db3l\buildarea\3.5.bolen-windows7\build\lib\test\test_pydoc.py", line 458, in test_mixed_case_module_names_are_lower_cased
self.assertIn('xml.etree.elementtree', doc_link)
File "D:\cygwin\home\db3l\buildarea\3.5.bolen-windows7\build\lib\unittest\case.py", line 1076, in assertIn
if member not in container:
TypeError: argument of type 'NoneType' is not iterable |
Kaushik or David (or anyone else), does you have an idea of how to fix the Windows tests? It would be good to make the buildbots healthy again, then it is easier to see new failures in Windows. |
Those are the only failures on 2 of the 4 buildbots running gui tests. |
My guess is the file.startswith(basedir) in the getdocloc() method is getting tricked by non-canonical paths (e.g. lowercase vs uppercase C: drive?). Would it help to use something like os.path.normcase(), or maybe os.path.commonpath(), pathlib.PurePath.parts or PurePath.relative_to()? file = inspect.getabsfile(object)
...
basedir = os.path.normcase(basedir)
if (...
(file.startswith(basedir) and ... Also, in the new get_pydoc_link() function, is that os.path.join() call meant to be there? basedir = os.path.join(dirname(dirname(__file__))) |
|
New changeset d84268ed62ac by Martin Panter in branch '3.5': New changeset 84d1e5a4b1c5 by Martin Panter in branch 'default': |
New changeset c60d2e4f4f96 by Martin Panter in branch '2.7': |
Thanks Kaushik. I also changed the https:// detection to also detect http://, to maintain backwards compatibility. I am porting these changes to 2.7. |
New changeset ede10138327e by Martin Panter in branch '2.7': |
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: