Skip to content
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

Idle: remove idlelib.idlever.py and its use in About dialog #68387

Closed
terryjreedy opened this issue May 15, 2015 · 14 comments
Closed

Idle: remove idlelib.idlever.py and its use in About dialog #68387

terryjreedy opened this issue May 15, 2015 · 14 comments
Assignees
Labels
topic-IDLE type-feature A feature request or enhancement

Comments

@terryjreedy
Copy link
Member

BPO 24199
Nosy @brettcannon, @terryjreedy, @larryhastings, @benjaminp, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/terryjreedy'
closed_at = <Date 2015-09-20.06:36:04.310>
created_at = <Date 2015-05-15.00:38:05.387>
labels = ['expert-IDLE', 'type-feature']
title = 'Idle: remove idlelib.idlever.py and its use in About dialog'
updated_at = <Date 2015-09-20.06:36:04.309>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2015-09-20.06:36:04.309>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = True
closed_date = <Date 2015-09-20.06:36:04.310>
closer = 'terry.reedy'
components = ['IDLE']
creation = <Date 2015-05-15.00:38:05.387>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 24199
keywords = []
message_count = 14.0
messages = ['243237', '243246', '243263', '243380', '243381', '243620', '243862', '250248', '250250', '250288', '250290', '250975', '251047', '251151']
nosy_count = 7.0
nosy_names = ['brett.cannon', 'terry.reedy', 'larry', 'benjamin.peterson', 'Arfrever', 'python-dev', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue24199'
versions = ['Python 3.6']

@terryjreedy
Copy link
Member Author

Once upon a time, Idle was versioned separately from Python, though updated in lockstep with Python (bpo-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.

@terryjreedy terryjreedy self-assigned this May 15, 2015
@terryjreedy terryjreedy added topic-IDLE type-feature A feature request or enhancement labels May 15, 2015
@benjaminp
Copy link
Contributor

That's fine. Just delete idlever.py, and I'll deal with it.

@serhiy-storchaka
Copy link
Member

Are there third-party IDLE plugins? If yes, this change can break them.

@python-dev
Copy link
Mannequin

python-dev mannequin commented May 16, 2015

New changeset c473ac171041 by Terry Jan Reedy in branch '2.7':
Issue bpo-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 bpo-24199: Make idlever module self updating. Syop using it in aboutDialog.
https://hg.python.org/cpython/rev/c862166060ed

@terryjreedy
Copy link
Member Author

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?

@terryjreedy
Copy link
Member Author

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.)

@python-dev
Copy link
Mannequin

python-dev mannequin commented May 22, 2015

New changeset 117af4bc0513 by Benjamin Peterson in branch '2.7':
make idlever.py self-updating (closes bpo-24199)
https://hg.python.org/cpython/rev/117af4bc0513

@python-dev python-dev mannequin closed this as completed May 22, 2015
@terryjreedy
Copy link
Member Author

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?

@terryjreedy terryjreedy reopened this Sep 8, 2015
@brettcannon
Copy link
Member

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.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Sep 9, 2015

New changeset 55b62e2c59f8 by Terry Jan Reedy in branch '2.7':
bpo-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':
bpo-24199: Deprecate idlelib.idlever with a warning on import.
https://hg.python.org/cpython/rev/c51514826126

@terryjreedy
Copy link
Member Author

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.

  1. 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.

@Arfrever
Copy link
Mannequin

Arfrever mannequin commented Sep 18, 2015

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)
$

@terryjreedy
Copy link
Member Author

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.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Sep 20, 2015

New changeset 3c39413d277f by Terry Jan Reedy in branch '2.7':
Issue bpo-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 bpo-24199: Add stacklevel to deprecation warning call.
https://hg.python.org/cpython/rev/048fce602bcd

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-IDLE type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants