Repository navigation
Deprecate imp #61379
Copy link
Copy link
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
| BPO | 17177 |
|---|---|
| Nosy | @brettcannon, @vstinner, @benjaminp, @ezio-melotti, @merwok, @bitdancer |
| Dependencies |
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/brettcannon'
closed_at = <Date 2013-06-19.00:52:10.759>
created_at = <Date 2013-02-10.20:08:31.548>
labels = ['type-feature', 'library']
title = 'Deprecate imp'
updated_at = <Date 2013-06-19.00:52:10.758>
user = 'https://github.com/brettcannon'bugs.python.org fields:
activity = <Date 2013-06-19.00:52:10.758>
actor = 'brett.cannon'
assignee = 'brett.cannon'
closed = True
closed_date = <Date 2013-06-19.00:52:10.759>
closer = 'brett.cannon'
components = ['Library (Lib)']
creation = <Date 2013-02-10.20:08:31.548>
creator = 'brett.cannon'
dependencies = ['14797', '17907', '18192', '18193', '18194']
files = []
hgrepos = []
issue_num = 17177
keywords = []
message_count = 38.0
messages = ['181849', '182152', '182155', '182165', '182168', '182173', '187251', '187305', '187306', '187361', '187364', '187366', '188387', '188390', '188391', '188392', '190984', '191187', '191188', '191189', '191190', '191191', '191192', '191193', '191215', '191216', '191218', '191220', '191221', '191235', '191237', '191238', '191240', '191243', '191247', '191274', '191422', '191442']
nosy_count = 8.0
nosy_names = ['brett.cannon', 'vstinner', 'benjamin.peterson', 'ezio.melotti', 'eric.araujo', 'Arfrever', 'r.david.murray', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'test needed'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue17177'
versions = ['Python 3.4']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Activity
brettcannon commentedon Feb 10, 2013
I need a make a decision as to what (if anything) belongs in imp and then document what stays and deprecate everything else.
Everything in imp falls into one of the following categories:
The question is what to keep/expose in imp and what to deprecate. Basically I need to figure out what imp's role is supposed to be in the face of importlib. My gut says either expose platform-dependent stuff and reload() and move the rest to importlib/deprecate, or to completely do away with the module and force people to use the APIs in importlib for consistency (and to stop people from mucking around with import from outside of importlib).
merwok commentedon Feb 15, 2013
I’ve always perceived imp as an implementation detail of the import system that people were sometimes forced to use to get to some things. Now that we have importlib, deprecating (with a nice long compatibility-with-warnings period) sounds good.
Would checking with the other VMs be a good idea?
brettcannon commentedon Feb 15, 2013
Checking with the other VMs wouldn't benefit anyone. They still have to implement whatever is necessary from _imp in order for importlib to work. Otherwise it's just another stdlib module.
ezio-melotti commentedon Feb 15, 2013
If it's not even clear for you, even if you eventually figure that out, having two import-related modules is likely to be confusing for users.
OTOH deprecating/removing imp would affect the somewhat popular imp.reload(), that has already been moved for Python 3, and will now be moved again (this also means that the -3 warnings on 2.7 will no longer be valid).
brettcannon commentedon Feb 15, 2013
I would probably document the deprecation but otherwise leave it alone at the module level. Considering I only documented imp.find_module() and .load_module() as documented thanks to their funky interfaces making nearly impossible to do a direct translation I don't see how I can justify raising a DeprecationWarning for the whole thing.
But it's gone in Python 4. =)
ezio-melotti commentedon Feb 15, 2013
If you move them to importlib and just leave an alias in imp, you should still add a DeprecationWarning IMHO, even if you plan to remove them in Python 4.
bitdancer commentedon Apr 18, 2013
The documentation deprecation has been added as part of bpo-17135.
Leaving this open to address Ezio's last comment.
vstinner commentedon Apr 18, 2013
If the imp module is marked as deprecated, it would help to explain how to port code from imp to importlib. As it was done for os.spawn(), platform.popen(), etc.
I'm using imp.load_source() in my setup.py to load a version.py file which only contains constants, to be able to build my module even if executing the module fails (ex: because of a runtime dependency). I don't know how to change my code to use imp.load_source().
vstinner commentedon Apr 18, 2013
Woops, I mean "to use importlib".
brettcannon commentedon Apr 19, 2013
The deprecation warnings for the explicitly deprecated functions already have the instructions on how to port. A note could probably be added to turn on deprecation warnings if one needs help with moving code over.
But the deprecation isn't even officially full-on yet. While it's documented as such, not all functionality has moved over to importlib, only bits and pieces.
bitdancer commentedon Apr 19, 2013
Should we back out that module level deprecation notice for the moment, then?
brettcannon commentedon Apr 19, 2013
Nah, consider it motivation for me to get it done in Python 3.4 else I have to back it out before release.
16 remaining items
python-dev commentedon Jun 15, 2013
New changeset 8fff5554125d by Brett Cannon in branch 'default':
Issue bpo-17177: switch from imp.new_module to types.ModuleType for runpy
http://hg.python.org/cpython/rev/8fff5554125d
python-dev commentedon Jun 15, 2013
New changeset 1e141c2cc0d7 by Brett Cannon in branch 'default':
Issue bpo-17177: Stop using imp in sysconfig
http://hg.python.org/cpython/rev/1e141c2cc0d7
python-dev commentedon Jun 15, 2013
New changeset bc18b5d4920e by Brett Cannon in branch 'default':
Issue bpo-17177: Stop using imp in a bunch of tests
http://hg.python.org/cpython/rev/bc18b5d4920e
python-dev commentedon Jun 15, 2013
New changeset f96eb1dc335f by Brett Cannon in branch 'default':
Issue bpo-17177: Stop using imp in zipfile
http://hg.python.org/cpython/rev/f96eb1dc335f
New changeset b2b2bdc4cf6f by Brett Cannon in branch 'default':
Issue bpo-17177: Stop using imp in turtledemo
http://hg.python.org/cpython/rev/b2b2bdc4cf6f
python-dev commentedon Jun 15, 2013
New changeset 4a1161eaed99 by Brett Cannon in branch 'default':
Issue bpo-17177: Stop using imp in setup.py
http://hg.python.org/cpython/rev/4a1161eaed99
python-dev commentedon Jun 15, 2013
New changeset ca3bdac1f88a by Brett Cannon in branch 'default':
Issue bpo-17177: update checkpyc to stop using imp
http://hg.python.org/cpython/rev/ca3bdac1f88a
python-dev commentedon Jun 15, 2013
New changeset 5e8b377942f7 by Brett Cannon in branch 'default':
Issue bpo-17177: stop using imp in test_importlib
http://hg.python.org/cpython/rev/5e8b377942f7
brettcannon commentedon Jun 15, 2013
At this point I have updated all the code that does not directly exposes imp somehow or in Tools.
At this point the only thing I need to decide is whether I want to continue to expose the lock stuff from imp or leave it private. After that the pending deprecation is ready to go.
python-dev commentedon Jun 16, 2013
New changeset 1b8f08c4efd5 by Brett Cannon in branch 'default':
Issue bpo-17177: The imp module is pending deprecation.
http://hg.python.org/cpython/rev/1b8f08c4efd5
brettcannon commentedon Jun 18, 2013
Going to temporarily re-open to remind me to add better deprecation docs for imp.load_module() to point to specific loader in importlib.machinery.
Should also add example usage as well.
python-dev commentedon Jun 19, 2013
New changeset ded443c603f0 by Brett Cannon in branch 'default':
Issue bpo-17177: Clarify some deprecations
http://hg.python.org/cpython/rev/ded443c603f0