Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78d915a

Browse files
committed
Issue 24199: Deprecate idlelib.idlever with a warning on import.
1 parent bf19d16 commit 78d915a

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

Lib/idlelib/idle_test/test_warning.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ def test_shell_show(self):
6868
'Test', UserWarning, 'test_warning.py', 99, f, 'Line of code')
6969
self.assertEqual(shellmsg.splitlines(), f.getvalue().splitlines())
7070

71+
class ImportWarnTest(unittest.TestCase):
72+
def test_idlever(self):
73+
with warnings.catch_warnings(record=True) as w:
74+
warnings.simplefilter("always")
75+
import idlelib.idlever
76+
self.assertEqual(len(w), 1)
77+
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
78+
self.assertIn("version", str(w[-1].message))
79+
7180

7281
if __name__ == '__main__':
7382
unittest.main(verbosity=2, exit=False)

Lib/idlelib/idlever.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
"""Unused by Idle: there is no separate Idle version anymore.
2-
Kept only for possible existing extension use."""
1+
"""
2+
The separate Idle version was eliminated years ago;
3+
idlelib.idlever is no longer used by Idle
4+
and will be removed in 3.6 or later. Use
5+
from sys import version
6+
IDLE_VERSION = version[:version.index(' ')]
7+
"""
8+
# Kept for now only for possible existing extension use
9+
import warnings as w
10+
w.warn(__doc__, DeprecationWarning)
311
from sys import version
412
IDLE_VERSION = version[:version.index(' ')]
5-

0 commit comments

Comments
 (0)