Skip to content

IDLE: adjust Python version in doc url for 3.10+ #28228

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

Merged
merged 2 commits into from
Sep 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Lib/idlelib/help_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from idlelib import textview

version = python_version()


def build_bits():
"Return bits for platform."
Expand Down Expand Up @@ -42,7 +44,7 @@ def __init__(self, parent, title=None, *, _htest=False, _utest=False):
self.create_widgets()
self.resizable(height=False, width=False)
self.title(title or
f'About IDLE {python_version()} ({build_bits()} bit)')
f'About IDLE {version} ({build_bits()} bit)')
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.ok)
Expand Down Expand Up @@ -88,8 +90,8 @@ def create_widgets(self):
email = Label(frame_background, text='email: [email protected]',
justify=LEFT, fg=self.fg, bg=self.bg)
email.grid(row=6, column=0, columnspan=2, sticky=W, padx=10, pady=0)
docs = Label(frame_background, text='https://docs.python.org/' +
python_version()[:3] + '/library/idle.html',
docs = Label(frame_background, text="https://docs.python.org/"
f"{version[:version.rindex('.')]}/library/idle.html",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not guaranteed that the Python version contains exactly 2 dots. This code will not work with versions containing 1 or 3 dots.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also Lib/idlelib/editor.py.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not guaranteed that the Python version contains exactly 2 dots.

Can you give an example where that's not the case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.2? Also we can release a micro-bugfix in future, like 3.11.2.1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, TIL that 2.7 and 3.2 were indeed missing the micro version in their initial releases. However:

  1. We haven't done that since and even in those releases sys.version_info included micro equal to 0.
  2. The code in this PR uses platform.python_version which is specifically documented like this:
    """ Returns the Python version as string 'major.minor.patchlevel'

        Note that unlike the Python sys.version, the returned value
        will always include the patchlevel (it defaults to 0).
    """
  1. We actually literally cannot release versions with a fourth component because no downstream tooling expects that. If we need to recall a version due to a big issue, we simply bump the third number.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. But all other code uses sys.version_info[:2] instead of parsing platform.python_version() if it needs a 2-component version. I think it is more reliable.

justify=LEFT, fg=self.fg, bg=self.bg)
docs.grid(row=7, column=0, columnspan=2, sticky=W, padx=10, pady=0)

Expand All @@ -98,7 +100,7 @@ def create_widgets(self):
columnspan=3, padx=5, pady=5)

pyver = Label(frame_background,
text='Python version: ' + python_version(),
text='Python version: ' + version,
fg=self.fg, bg=self.bg)
pyver.grid(row=9, column=0, sticky=W, padx=10, pady=0)
tkver = Label(frame_background, text='Tk version: ' + tk_patchlevel,
Expand All @@ -124,7 +126,7 @@ def create_widgets(self):
columnspan=3, padx=5, pady=5)

idlever = Label(frame_background,
text='IDLE version: ' + python_version(),
text='IDLE version: ' + version,
fg=self.fg, bg=self.bg)
idlever.grid(row=12, column=0, sticky=W, padx=10, pady=0)
idle_buttons = Frame(frame_background, bg=self.bg)
Expand Down