classification
Title: Idle: remove idlelib.idlever.py and its use in About dialog
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Arfrever, benjamin.peterson, brett.cannon, larry, python-dev, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2015-05-15 00:38 by terry.reedy, last changed 2015-09-20 06:36 by terry.reedy. This issue is now closed.

Messages (14)
msg243237 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-05-15 00:38
Once upon a time, Idle was versioned separately from Python, though updated in lockstep with Python (#1515164, Martin's comment). The version was kept in idlever.py, with one line
IDLE_VERSION = "m.n.p"

Several years ago, the separate versioning was dropped (or decreed to be the same as the Python version -- no issue for this). idlever.py was kept and made to contain the initial part of sys.version (sys.version.split()[0]).  It gets patched as part of the version bump process,  Most recently 80ccce248ba2 (Benjamin) and 413e0e0004f4 (Larry). Is that part of an automated script?

The only current use of idlever is for the About Idle box (aboutDialog.py), which prints two lines with redundant information:
'Python version:  ' + sys.version.split()[0]
'IDLE version:   ' + idlever.IDLE_VERSION

idlever.py is not needed and I intend to remove it.  But before or as I do, its patching needs to be removed from the version bump process.

I would also like to remove "IDLE version ..." from the dialog box, but even if not, idlever.py is not needed.
msg243246 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-05-15 05:14
That's fine. Just delete idlever.py, and I'll deal with it.
msg243263 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-15 11:29
Are there third-party IDLE plugins? If yes, this change can break them.
msg243380 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-16 23:34
New changeset c473ac171041 by Terry Jan Reedy in branch '2.7':
Issue #24199: Stop using idelver in aboutdialog.
https://hg.python.org/cpython/rev/c473ac171041

New changeset c862166060ed by Terry Jan Reedy in branch '3.4':
Issue #24199: Make idlever module self updating. Syop using it in aboutDialog.
https://hg.python.org/cpython/rev/c862166060ed
msg243381 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-05-16 23:39
Benjamim, I made idlever update from sys.version until removed, so remove it from release process.

Serhiy, yes there are extensions which might possibly use this private api, even if they really should not.  I want to bring Nick (PEP 434 approver) into the discussion of the timing of removal.

Is there any problem with respect to buildbots of raising a DeprecationWarning when a module is imported?  Is so, can a module be excluded from the import all test?
msg243620 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-05-19 19:22
To answer my question, I checked test___all__.py. The check_all helper has this:
        with support.check_warnings(
            (".* (module|package)", DeprecationWarning),
            ("", ResourceWarning),
            quiet=True):
I presume this means that DeprecationWarnings raised by the following import are suppressed.  (There is also a  blacklist.)
msg243862 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-22 22:55
New changeset 117af4bc0513 by Benjamin Peterson in branch '2.7':
make idlever.py self-updating (closes #24199)
https://hg.python.org/cpython/rev/117af4bc0513
msg250248 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-09-08 18:01
Re-opening because there is still the issue of adding a deprecation warning on import.  Brett, can you either point me toward or post here the code you are planning to use for other stdlib modules?
msg250250 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-09-08 18:11
Typically it's warnings.warn(message, DeprecationWarning, stacklevel=2), but that stack level is wrong for Python 3.3 - 3.4 (fixed in 3.5.0). If this is purely for Python 3.6 I might be adding a nicer API for module deprecations, but if this is for other versions then the call above is the right one except for Python 3.3/3.4.
msg250288 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-09 06:11
New changeset 55b62e2c59f8 by Terry Jan Reedy in branch '2.7':
Issue 24199: Deprecate idlelib.idlever with a warning on import.
https://hg.python.org/cpython/rev/55b62e2c59f8

New changeset c51514826126 by Terry Jan Reedy in branch '3.4':
Issue 24199: Deprecate idlelib.idlever with a warning on import.
https://hg.python.org/cpython/rev/c51514826126
msg250290 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-09-09 06:25
Thanks, Brett. Since I am not wrapping the warning, the default stacklevel seems to work on all versions.

Still to do: 1. Something in the docs (all branches), but with an eye toward other deprecations coming later.

2. Actually remove file in 3.6 branch, but only after ImportError does not crash Python when running without a console (ie, with sys.stderr == None)).  An future issue to fix this will be a dependency.
msg250975 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2015-09-18 13:06
> Since I am not wrapping the warning, the default stacklevel seems to work on all versions.

The purpose of stacklevel=2 here would be to make warning message indicate which file contains import of deprecated module.

See below example, which shows that stacklevel=2 in formatter.py and imp.py results in message pointing to bbb.py as containing imports of deprecated modules:

$ cat aaa.py
import bbb
$ cat bbb.py
import formatter
import imp
import idlelib.idlever
$ python3.5 -Wd -c 'import aaa'
/tmp/bbb.py:1: DeprecationWarning: the formatter module is deprecated and will be removed in Python 3.6
  import formatter
/tmp/bbb.py:2: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
/usr/lib64/python3.5/idlelib/idlever.py:10: DeprecationWarning: 
The separate Idle version was eliminated years ago;
idlelib.idlever is no longer used by Idle
and will be removed in 3.6 or later.  Use
    from sys import version
    IDLE_VERSION = version[:version.index(' ')]

  w.warn(__doc__, DeprecationWarning)
$
msg251047 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-09-19 02:20
I get it now: the last line should be 'import idlelib.idlever' instead of the redundant line from idlever itself.  Will change, and thanks for correcting this before I so the same in multiple other modules.
msg251151 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-20 06:35
New changeset 3c39413d277f by Terry Jan Reedy in branch '2.7':
Issue #24199: Add stacklevel to deprecation warning call.
https://hg.python.org/cpython/rev/3c39413d277f

New changeset 048fce602bcd by Terry Jan Reedy in branch '3.4':
Issue #24199: Add stacklevel to deprecation warning call.
https://hg.python.org/cpython/rev/048fce602bcd
History
Date User Action Args
2015-09-20 06:36:04terry.reedysetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2015-09-20 06:35:10python-devsetmessages: + msg251151
2015-09-19 02:20:05terry.reedysetmessages: + msg251047
2015-09-18 13:06:10Arfreversetnosy: + Arfrever
messages: + msg250975
2015-09-09 06:25:22terry.reedysetmessages: + msg250290
versions: + Python 3.6, - Python 2.7, Python 3.4, Python 3.5
2015-09-09 06:11:50python-devsetmessages: + msg250288
2015-09-08 18:11:01brett.cannonsetmessages: + msg250250
2015-09-08 18:01:46terry.reedysetstatus: closed -> open

nosy: + brett.cannon
messages: + msg250248

resolution: fixed -> (no value)
stage: resolved -> needs patch
2015-05-22 22:55:30python-devsetstatus: open -> closed
resolution: fixed
messages: + msg243862

stage: needs patch -> resolved
2015-05-19 19:22:18terry.reedysetmessages: + msg243620
2015-05-16 23:39:24terry.reedysetmessages: + msg243381
2015-05-16 23:34:12python-devsetnosy: + python-dev
messages: + msg243380
2015-05-15 11:30:00serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg243263
2015-05-15 05:14:20benjamin.petersonsetmessages: + msg243246
2015-05-15 00:38:05terry.reedycreate