Skip to content

Deprecate imp #61379

Closed
Closed

Description

@brettcannon
BPO 17177
Nosy @brettcannon, @vstinner, @benjaminp, @ezio-melotti, @merwok, @bitdancer
Dependencies
  • bpo-14797: Deprecate imp.find_module()/load_module()
  • bpo-17907: Deprecate imp.new_module() in favour of types.ModuleType
  • bpo-18192: Move imp.get_magic() to importlib
  • bpo-18193: Move imp.reload() to importlib
  • bpo-18194: Move imp.source_from_cache/cache_from_source to importlib
  • 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']

    Activity

    1. brettcannon commented on Feb 10, 2013

      @brettcannon
      MemberAuthor

      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:

      • From importlib
        • get_magic()
        • source_from_cache()
        • cache_from_source()
      • From sys
        • get_tag()
      • Platform-implemented
        • lock_held()
        • acquire_lock()
        • release_lock()
        • Undocumented stuff related to builtins, frozen, and load_dynamic()
      • Helper
        • reload()

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

    2. self-assigned this
      on Feb 10, 2013
    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Feb 10, 2013
    4. merwok commented on Feb 15, 2013

      @merwok
      Member

      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?

    5. brettcannon commented on Feb 15, 2013

      @brettcannon
      MemberAuthor

      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.

    6. ezio-melotti commented on Feb 15, 2013

      @ezio-melotti
      Member

      Basically I need to figure out what imp's role is supposed to be in the face of importlib.

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

    7. brettcannon commented on Feb 15, 2013

      @brettcannon
      MemberAuthor

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

    8. ezio-melotti commented on Feb 15, 2013

      @ezio-melotti
      Member

      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.

    9. bitdancer commented on Apr 18, 2013

      @bitdancer
      Member

      The documentation deprecation has been added as part of bpo-17135.

      Leaving this open to address Ezio's last comment.

    10. vstinner commented on Apr 18, 2013

      @vstinner
      Member

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

    11. vstinner commented on Apr 18, 2013

      @vstinner
      Member

      I don't know how to change my code to use imp.load_source().

      Woops, I mean "to use importlib".

    12. brettcannon commented on Apr 19, 2013

      @brettcannon
      MemberAuthor

      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.

    13. bitdancer commented on Apr 19, 2013

      @bitdancer
      Member

      Should we back out that module level deprecation notice for the moment, then?

    14. brettcannon commented on Apr 19, 2013

      @brettcannon
      MemberAuthor

      Nah, consider it motivation for me to get it done in Python 3.4 else I have to back it out before release.

    15. 16 remaining items

    16. python-dev commented on Jun 15, 2013

      python-devmannequin
      Mannequin

      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

    17. python-dev commented on Jun 15, 2013

      python-devmannequin
      Mannequin

      New changeset 1e141c2cc0d7 by Brett Cannon in branch 'default':
      Issue bpo-17177: Stop using imp in sysconfig
      http://hg.python.org/cpython/rev/1e141c2cc0d7

    18. python-dev commented on Jun 15, 2013

      python-devmannequin
      Mannequin

      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

    19. python-dev commented on Jun 15, 2013

      python-devmannequin
      Mannequin

      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

    20. python-dev commented on Jun 15, 2013

      python-devmannequin
      Mannequin

      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

    21. python-dev commented on Jun 15, 2013

      python-devmannequin
      Mannequin

      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

    22. python-dev commented on Jun 15, 2013

      python-devmannequin
      Mannequin

      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

    23. brettcannon commented on Jun 15, 2013

      @brettcannon
      MemberAuthor

      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.

    24. python-dev commented on Jun 16, 2013

      python-devmannequin
      Mannequin

      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

    25. brettcannon commented on Jun 18, 2013

      @brettcannon
      MemberAuthor

      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.

    26. python-dev commented on Jun 19, 2013

      python-devmannequin
      Mannequin

      New changeset ded443c603f0 by Brett Cannon in branch 'default':
      Issue bpo-17177: Clarify some deprecations
      http://hg.python.org/cpython/rev/ded443c603f0

    27. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions