Skip to content

bpo-43044: [2.7] Doc: Stop linking to non-existent pages. #24195

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

Closed
wants to merge 1 commit into from

Conversation

verhovsky
Copy link
Contributor

@verhovsky verhovsky commented Jan 11, 2021

Currently, visiting https://docs.python.org/2/library/stringio.html and clicking the "You should upgrade and read the Python documentation for the current stable release." link in the header sends you to https://docs.python.org/3/library/stringio.html which is a 404 Error page. This pull requests changes that link to https://docs.python.org/3/library/io.html#io.StringIO

Pages that have been completely removed in Python 3 now link to https://docs.python.org/3/index.html

I also added a few alternatives in comments if someone has any thoughts. (See python/pythondotorg#1719 for details)

https://bugs.python.org/issue43044

@tirkarthi
Copy link
Member

Adding @benjaminp since this is changes for 2.7 and has reached EoL.

@verhovsky
Copy link
Contributor Author

Here's a clickable list of the redirects I've added:

Python 2 Python 3
library/fpformat
library/mutex
library/new
library/statvfs
library/dircache
library/macpath
library/dbhash
library/bsddb
library/someos
library/popen2
library/mhlib
library/mimetools
library/mimewriter
library/mimify
library/multifile
library/sgmllib
library/imageop
library/hotshot
library/future_builtins
library/user
library/fpectl
library/restricted
library/rexec
library/bastion
library/imputil
library/compiler
library/dl
library/posixfile
library/commands
library/mac
library/ic
library/macos
library/macostools
library/easydialogs
library/framework
library/autogil
library/carbon
library/colorpicker
library/macosa
library/gensuitemodule
library/aetools
library/aepack
library/aetypes
library/miniaeframe
library/sgi
library/al
library/cd
library/fl
library/fm
library/gl
library/imgfile
library/jpeg
library/sun
library/sunaudio
c-api/int
c-api/string
c-api/class
c-api/cobject
howto/doanddont
howto/webservers
library/strings library/text.html
library/stringio library/io.html#io.StringIO
library/sets
library/userdict library/collections.html#userdict-objects
library/repr library/reprlib.html
library/copy_reg library/copyreg.html
library/anydbm library/dbm.html
library/whichdb library/dbm.html#dbm.whichdb
library/dumbdbm library/dbm.html#module-dbm.dumb
library/dbm library/dbm.html#module-dbm.ndbm
library/gdbm library/dbm.html#module-dbm.gnu
library/robotparser library/urllib.robotparser.html
library/md5
library/sha
library/thread library/_thread.html
library/dummy_thread
library/email-examples library/email.examples.html
library/rfc822
library/htmlparser library/html.parser.html
library/htmllib
library/urllib2 library/urllib.request.html
library/httplib library/http.client.html
library/urlparse library/urllib.parse.html
library/basehttpserver library/http.server.html
library/simplehttpserver library/http.server.html#http.server.SimpleHTTPRequestHandler
library/cgihttpserver library/http.server.html#http.server.CGIHTTPRequestHandler
library/cookielib library/http.cookiejar.html
library/cookie library/http.cookies.html
library/xmlrpclib library/xmlrpc.client.html
library/simplexmlrpcserver library/xmlrpc.server.html
library/docxmlrpcserver library/xmlrpc.server.html#documenting-xmlrpc-server
library/ttk library/tkinter.ttk.html
library/tix library/tkinter.tix.html
library/scrolledtext library/tkinter.scrolledtext.html
library/__builtin__ library/builtins.html
library/_winreg library/winreg.html

And the code to generate it:

moved_files = {
    "library/fpformat": None,
    "library/mutex": None,
    "library/new": None,
    "library/statvfs": None,
    "library/dircache": None,
    "library/macpath": None,
    "library/dbhash": None,
    "library/bsddb": None,
    # 'library/someos': 'library/index',
    "library/someos": None,
    # 'library/popen2': 'library/subprocess',
    "library/popen2": None,
    # 'library/mhlib': 'library/mailbox',
    "library/mhlib": None,
    # 'library/mimetools': 'library/email',
    "library/mimetools": None,
    # 'library/mimewriter': 'library/email',
    "library/mimewriter": None,
    # 'library/mimify': 'library/email',
    "library/mimify": None,
    # 'library/multifile': 'library/email',
    "library/multifile": None,
    "library/sgmllib": None,
    "library/imageop": None,
    # 'library/hotshot': 'library/profile',
    "library/hotshot": None,
    "library/future_builtins": None,
    "library/user": None,
    "library/fpectl": None,
    "library/restricted": None,
    "library/rexec": None,
    "library/bastion": None,
    "library/imputil": None,
    "library/compiler": None,
    # 'library/dl': 'library/ctypes',
    "library/dl": None,
    "library/posixfile": None,
    # 'library/commands': 'library/subprocess',
    "library/commands": None,
    "library/mac": None,
    "library/ic": None,
    "library/macos": None,
    "library/macostools": None,
    "library/easydialogs": None,
    "library/framework": None,
    "library/autogil": None,
    "library/carbon": None,
    "library/colorpicker": None,
    "library/macosa": None,
    "library/gensuitemodule": None,
    "library/aetools": None,
    "library/aepack": None,
    "library/aetypes": None,
    "library/miniaeframe": None,
    "library/sgi": None,
    "library/al": None,
    "library/cd": None,
    "library/fl": None,
    "library/fm": None,
    "library/gl": None,
    "library/imgfile": None,
    "library/jpeg": None,
    "library/sun": None,
    "library/sunaudio": None,
    # 'c-api/int': 'c-api/long',
    "c-api/int": None,
    # 'c-api/string': 'c-api/bytes',
    "c-api/string": None,
    "c-api/class": None,
    # 'c-api/cobject': 'c-api/capsule',
    "c-api/cobject": None,
    "howto/doanddont": None,
    "howto/webservers": None,
    "library/strings": "library/text",
    "library/stringio": ("library/io", "io.StringIO"),
    # 'library/sets': ('library/stdtypes', 'set'),
    # 'library/sets': ('library/stdtypes', 'set-types-set-frozenset'),
    "library/sets": None,
    "library/userdict": ("library/collections", "userdict-objects"),
    "library/repr": "library/reprlib",
    "library/copy_reg": "library/copyreg",
    "library/anydbm": "library/dbm",
    "library/whichdb": ("library/dbm", "dbm.whichdb"),
    "library/dumbdbm": ("library/dbm", "module-dbm.dumb"),
    "library/dbm": ("library/dbm", "module-dbm.ndbm"),
    "library/gdbm": ("library/dbm", "module-dbm.gnu"),
    "library/robotparser": "library/urllib.robotparser",
    # 'library/md5': 'library/hashlib',
    "library/md5": None,
    # 'library/sha': 'library/hashlib',
    "library/sha": None,
    "library/thread": "library/_thread",
    # Renamed to _dummy_thread but has since been removed completely
    # 'library/dummy_thread': 'library/_dummy_thread',
    "library/dummy_thread": None,
    "library/email-examples": "library/email.examples",
    # 'library/rfc822': 'library/email',
    "library/rfc822": None,
    "library/htmlparser": "library/html.parser",
    "library/htmllib": None,
    # 'library/urllib2': 'library/urllib',
    "library/urllib2": "library/urllib.request",
    "library/httplib": "library/http.client",
    "library/urlparse": "library/urllib.parse",
    "library/basehttpserver": "library/http.server",
    "library/simplehttpserver": ("library/http.server", "http.server.SimpleHTTPRequestHandler"),
    "library/cgihttpserver": ("library/http.server", "http.server.CGIHTTPRequestHandler"),
    "library/cookielib": "library/http.cookiejar",
    "library/cookie": "library/http.cookies",
    "library/xmlrpclib": "library/xmlrpc.client",
    "library/simplexmlrpcserver": "library/xmlrpc.server",
    "library/docxmlrpcserver": ("library/xmlrpc.server", "documenting-xmlrpc-server"),
    "library/ttk": "library/tkinter.ttk",
    "library/tix": "library/tkinter.tix",
    "library/scrolledtext": "library/tkinter.scrolledtext",
    "library/__builtin__": "library/builtins",
    "library/_winreg": "library/winreg",
}

from tabulate import tabulate

rows = []
for old, new in moved_files.items():
    if new is None:
        new = ""
    elif isinstance(new, str):
        new = f"[`{new}.html`](https://docs.python.org/3/{new}.html)"
    else:
        new = f"[`{new[0]}.html#{new[1]}`](https://docs.python.org/3/{new[0]}.html#{new[1]})"
    rows.append([f"[`{old}`](https://docs.python.org/2/{old}.html)", new])

print(
    tabulate(
        rows,
        headers=["Python 2", "Python 3"],
        tablefmt="github",
    )
)

You can find a list of all the files that are missing between Python 2.7 and Python 3.8 by downloading a copy of the documentation, then using comm against the output of find in the two directories. This misses any files that are completely different but still named the same but I don't think that happened.

wget https://docs.python.org/2/archives/python-2.7.18-docs-html.zip
unzip python-2.7.18-docs-html.zip

wget https://docs.python.org/3/archives/python-3.9.1-docs-html.zip  # new link at https://docs.python.org/3/download.html
unzip python-3.9.1-docs-html.zip

comm -23 <(find python-2.7.18-docs-html/ | cut -d'/' -f2- | sort) <(find python-3.9.1-docs-html/ | cut -d'/' -f2- | sort)

@ned-deily ned-deily closed this Jan 27, 2021
@ned-deily ned-deily deleted the branch python:2.7 January 27, 2021 15:31
@ned-deily
Copy link
Member

Sorry, the PR was closed automatically when the 2.7 branch was recently deleted, not through explicit action. The behavior you describe is certainly not ideal. Perhaps there is another way to solve the problem: create redirects or some such in the 3 doc tree or server config rather than modifying the now-frozen 2.7 source? Pinging @JulienPalard. And, to pursue this further, please open an issue on the Python bug tracker: https://bugs.python.org.

@verhovsky verhovsky changed the title [2.7] Doc: Stop linking to non-existent pages. bpo-43044 [2.7] Doc: Stop linking to non-existent pages. Jan 27, 2021
@verhovsky verhovsky changed the title bpo-43044 [2.7] Doc: Stop linking to non-existent pages. bpo-43044: [2.7] Doc: Stop linking to non-existent pages. Jan 27, 2021
@JulienPalard
Copy link
Member

Yes I'd prefer doing this on the nginx config instead on the non-existing 2.7 branch, as I previously did a few times here: https://github.com/python/psf-salt/blob/3f0c2941fe7df2dad29fe669811291b991eb677a/salt/docs/config/nginx.docs-backend.conf#L38

@verhovsky would you mind converting your PR to nginx syntax, on https://github.com/python/psf-salt/?

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

Successfully merging this pull request may close these issues.

7 participants