Skip to content

2to3 does not correct "reload" #56006

Closed
Closed

Description

@tebeka
mannequin
BPO 11797
Nosy @birkenfeld, @rhettinger, @jcea, @tebeka, @benjaminp, @ezio-melotti, @merwok, @bitdancer, @Bluehorn, @berkerpeksag
Files
  • fix_reload.diff: reload fixer for 2to3
  • fix_reload.py: reload fixer without copyright notice
  • issue11797.diff
  • issue11797_v2.diff
  • 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/benjaminp'
    closed_at = <Date 2012-12-08.03:44:17.444>
    created_at = <Date 2011-04-07.15:57:22.808>
    labels = ['easy', 'type-bug', 'expert-2to3']
    title = '2to3 does not correct "reload"'
    updated_at = <Date 2013-12-24.02:44:06.577>
    user = 'https://github.com/tebeka'

    bugs.python.org fields:

    activity = <Date 2013-12-24.02:44:06.577>
    actor = 'r.david.murray'
    assignee = 'benjamin.peterson'
    closed = True
    closed_date = <Date 2012-12-08.03:44:17.444>
    closer = 'python-dev'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2011-04-07.15:57:22.808>
    creator = 'tebeka'
    dependencies = []
    files = ['21568', '27875', '28084', '28222']
    hgrepos = []
    issue_num = 11797
    keywords = ['patch', 'easy']
    message_count = 17.0
    messages = ['133223', '133224', '133249', '133254', '133258', '138350', '141156', '141429', '141452', '174749', '174750', '174751', '176162', '176718', '177041', '177143', '206884']
    nosy_count = 14.0
    nosy_names = ['georg.brandl', 'rhettinger', 'jcea', 'tebeka', 'benjamin.peterson', 'ezio.melotti', 'eric.araujo', 'Arfrever', 'r.david.murray', 'torsten', 'BreamoreBoy', 'python-dev', 'BluePeppers', 'berker.peksag']
    pr_nums = []
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11797'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    Activity

    1. tebeka commented on Apr 7, 2011

      tebekamannequin
      MannequinAuthor

      The following code is not changed by 2to3::

      import os
      reload(os)
      

      reload has moved to the imp module.

    2. rhettinger commented on Apr 7, 2011

      @rhettinger
      Contributor

      This should get fixed, but I'm *really* curious about what kind of code actually needs to do this ;-)

    3. BluePeppers commented on Apr 7, 2011

      BluePeppersmannequin
      Mannequin

      Find a fixer for this attached. I really just did sed 's/intern/reload' fix_intern.py >fix_reload.py, but it seems to work. I didn't write any tests (I couldn't seem to find any for any other fixers).

    4. tebeka commented on Apr 7, 2011

      tebekamannequin
      MannequinAuthor

      Raymond: Sometimes I store configuration in Python files and would like to reload the configuration.

    5. rhettinger commented on Apr 7, 2011

      @rhettinger
      Contributor

      Miki: That's a really great use case. Thanks.

    6. Bluehorn commented on Jun 14, 2011

      Bluehornmannequin
      Mannequin

      The other use case I see is to reload a module during debugging after changing the code. This is especially useful for big GUI applications.

    7. merwok commented on Jul 26, 2011

      @merwok
      Member

      File looks good, although I’m not sure about the “Copyright 2006 Georg Brandl” line. I also don’t know if stable branches can get this fix.

    8. birkenfeld commented on Jul 30, 2011

      @birkenfeld
      Member

      I sure didn't have anything to do with that file :)

    9. BluePeppers commented on Jul 30, 2011

      BluePeppersmannequin
      Mannequin

      Ah, that's my fault. As I mentioned, I simply replaced sys with imp and intern with reload from fix_intern.py. Seeing as the vast majority of the file was not modified, I didn't bother to change the copyright notices.

    10. BreamoreBoy commented on Nov 4, 2012

      BreamoreBoymannequin
      Mannequin

      Please find attached a new file with the copyright notice removed. Would someone like to review it please.

    11. merwok commented on Nov 4, 2012

      @merwok
      Member

      FixIntern → FixReload

    12. merwok commented on Nov 4, 2012

      @merwok
      Member

      More importantly, tests would be great.

    13. berkerpeksag commented on Nov 23, 2012

      @berkerpeksag
      Member

      Here's a patch that adds tests and updates the documentation.

    14. benjaminp commented on Nov 30, 2012

      @benjaminp
      Contributor

      Thanks for the patch. Could you try to share could with fix_intern? Maybe by moving some things to fixer_utils.

    15. berkerpeksag commented on Dec 6, 2012

      @berkerpeksag
      Member

      Could you try to share could with fix_intern? Maybe by moving some
      things to fixer_utils.

      Thanks for the suggestion. Here's a new patch. I'm not sure the name of the helper is correct.

    16. python-dev commented on Dec 8, 2012

      python-devmannequin
      Mannequin

      New changeset 3576c0c6f860 by Benjamin Peterson in branch 'default':
      add fixer for reload() -> imp.reload() (closes bpo-11797)\n\nPatch by Laurie Clark-Michalek and Berker Peksag
      http://hg.python.org/cpython/rev/3576c0c6f860

    17. bitdancer commented on Dec 24, 2013

      @bitdancer
      Member

      Since this patch was applied, imp.reload has been deprecated in favor of importlib.reload. I don't know how we handle differences between python3 versions...is there anything that should be done here, or do we just use imp.reload even though it is deprecated in 3.4?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions