gh-91827: Add method info_pathlevel() in tkinter (GH-91829)

This commit is contained in:
Serhiy Storchaka 2022-05-06 13:50:38 +03:00 committed by GitHub
parent d707d073be
commit 15dbe8570f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 75 additions and 23 deletions

View file

@ -101,15 +101,7 @@ def get_tk_patchlevel():
global _tk_patchlevel
if _tk_patchlevel is None:
tcl = tkinter.Tcl()
patchlevel = tcl.call('info', 'patchlevel')
m = re.fullmatch(r'(\d+)\.(\d+)([ab.])(\d+)', patchlevel)
major, minor, releaselevel, serial = m.groups()
major, minor, serial = int(major), int(minor), int(serial)
releaselevel = {'a': 'alpha', 'b': 'beta', '.': 'final'}[releaselevel]
if releaselevel == 'final':
_tk_patchlevel = major, minor, serial, releaselevel, 0
else:
_tk_patchlevel = major, minor, 0, releaselevel, serial
_tk_patchlevel = tcl.info_patchlevel()
return _tk_patchlevel
units = {