Skip to content

Stop using deprecated imp module; imp should now emit a real DeprecationWarning #69347

Closed

Description

@vstinner
BPO 25160
Nosy @brettcannon, @ncoghlan, @vstinner, @ambv, @ericsnowcurrently, @berkerpeksag, @JelleZijlstra, @isidentical
PRs
  • bpo-35936: Updates to modulefinder #11787
  • bpo-35936: Updates to modulefinder #11787
  • Files
  • issue25160-2to3.patch: patch for lib2to3
  • 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 = None
    closed_at = <Date 2020-06-05.18:36:26.036>
    created_at = <Date 2015-09-18.07:06:19.691>
    labels = ['3.8', 'type-feature', 'library']
    title = 'Stop using deprecated imp module; imp should now emit a real DeprecationWarning'
    updated_at = <Date 2020-06-05.18:36:26.035>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-06-05.18:36:26.035>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-05.18:36:26.036>
    closer = 'brett.cannon'
    components = ['Library (Lib)']
    creation = <Date 2015-09-18.07:06:19.691>
    creator = 'vstinner'
    dependencies = []
    files = ['43113']
    hgrepos = []
    issue_num = 25160
    keywords = ['patch']
    message_count = 15.0
    messages = ['250946', '250948', '250949', '250950', '262467', '266914', '266929', '266931', '339564', '339565', '357975', '358127', '358194', '358196', '370778']
    nosy_count = 10.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'vstinner', 'Arfrever', 'lukasz.langa', 'python-dev', 'eric.snow', 'berker.peksag', 'JelleZijlstra', 'BTaskaya']
    pr_nums = ['11787', '11787']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25160'
    versions = ['Python 3.8']

    Activity

    1. vstinner commented on Sep 18, 2015

      @vstinner
      MemberAuthor

      The imp module is deprecated since Python 3.4. In Python 3.4, imp uses a PendingDeprecationWarning, and Python 3.5... hum, still a PendingDeprecationWarning. It was not supposed to become a real DeprecationWarning?

      Anyway, the imp module is still used in some places of the Python stdlib:

      Lib/modulefinder.py:14: import imp
      Python/makeopcodetargets.py:9:import imp
      Tools/i18n/pygettext.py:159:import imp
      Tools/importbench/importbench.py:10:import imp

      modulefinder explicitly ignore the warning :-(

      with warnings.catch_warnings():
          warnings.simplefilter('ignore', PendingDeprecationWarning)
          import imp
    2. berkerpeksag commented on Sep 18, 2015

      @berkerpeksag
      Member
    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Sep 18, 2015
    4. python-dev commented on Sep 18, 2015

      python-devmannequin
      Mannequin

      New changeset 03cd8340e0ce by Victor Stinner in branch '3.5':
      Issue bpo-25160: Fix import_init() comments and messages
      https://hg.python.org/cpython/rev/03cd8340e0ce

    5. berkerpeksag commented on Sep 18, 2015

      @berkerpeksag
      Member

      Lib/modulefinder.py:14: import imp

      I forgot to link bpo-20020 in my earlier message :)

    6. vstinner commented on Mar 25, 2016

      @vstinner
      MemberAuthor

      Tools/i18n/pygettext.py:159:import imp

      I opened the issue bpo-26639 for it.

      > Python/makeopcodetargets.py:9:import imp
      See bpo-20021.

      I pushed the change f682b620c64d but I forgot about the issue bpo-20021. Let's discuss there about this script.

      Tools/importbench/importbench.py:10:import imp

      I think that it's fine to keep imp there.

      Lib/modulefinder.py:14: import imp

      This one requires more work than the other.

    7. JelleZijlstra commented on Jun 2, 2016

      @JelleZijlstra
      Member

      Current status:

      I'll work on replacing some of these.

    8. JelleZijlstra commented on Jun 2, 2016

      @JelleZijlstra
      Member

      One more:

      • lib/pkgutil.py in _import_imp (amusingly) uses importlib with silenced warnings to import imp.
    9. berkerpeksag commented on Jun 2, 2016

      @berkerpeksag
      Member
      • 2to3 replaces reload() calls with imp.reload

      There is an already open issue for this: bpo-21446.

    10. ncoghlan commented on Apr 7, 2019

      @ncoghlan
      Contributor

      Fixed for Python 3.8 via the patch for bpo-35936.

    11. ncoghlan commented on Apr 7, 2019

      @ncoghlan
      Contributor

      Oops, this covers more than just modulefinder - reopening until the other remaining uses of the imp module have been removed.

    12. isidentical commented on Dec 7, 2019

      @isidentical
      SponsorMember

      @vstinner

      Tools/importbench/importbench.py:10:import imp
      I think that it's fine to keep imp there.

      Any reason to keep imp there? We can just port it to sole importlib (it already uses it in some places)

    13. brettcannon commented on Dec 9, 2019

      @brettcannon
      Member

      Any reason to keep imp there?

      Nope, not anymore.

    14. ambv commented on Dec 10, 2019

      @ambv
      Contributor

      Make sure the standard library doesn't emit those warnings itself.

    15. ambv commented on Dec 10, 2019

      @ambv
      Contributor

      I meant to comment on a different issue, the trigger is stuff like https://bugs.python.org/issue39015 (new deprecationwarnings being generated without cleaning up the standard library first).

    16. brettcannon commented on Jun 5, 2020

      @brettcannon
      Member

      imp has been moved to DeprecationWarning and I think its usage in the stdlib has been dealt with at this point.

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

    No one assigned

      Labels

      3.8 (EOL)end of lifestdlibStandard 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