Skip to content

Links to Python 3 docs in the warning header on Python 2.7 docs go to 404 pages when the library was removed in Python 3 #1719

Closed
@verhovsky

Description

@verhovsky

Describe the bug
There are a number of HTML files that were moved between the Python 2.7 and Python 3 documentation websites (because some libraries were moved, renamed and removed). The documentation for Python 2.7 contains a banner with a link to the current page with the "/2/" in the URL changed to "/3/". For the libraries that are missing from Python 3, these links open a 404 page.

To Reproduce

  1. Go to https://docs.python.org/2/library/stringio.html
  2. Click on "You should upgrade and read the Python documentation for the current stable release." at the very top.
  3. See a "404 Not Found" error

Expected behavior
Either (in order of preference)

Additional context
These are the files that are missing between Python 2.7 and Python 3.8 along with where (I think) they should be redirected to:

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

Code to generate the above table (I added some alternatives in comments - for example to libraries that replace the functionality of the removed package):

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

from tabulate import tabulate

print(
    tabulate(
        [
            (
                f"https://docs.python.org/2/{old}",
                "" if new is None else f"https://docs.python.org/3/{new}",
            )
            for old, new in redirects.items()
        ],
        headers=["Python 2", "Python 3"],
        tablefmt="github",
    )
)

See https://github.com/verhovsky/py3redirect/blob/master/special-cases.js for context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions