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

2to3 does not correct "reload" #56006

Closed
tebeka mannequin opened this issue Apr 7, 2011 · 17 comments
Closed

2to3 does not correct "reload" #56006

tebeka mannequin opened this issue Apr 7, 2011 · 17 comments
Assignees
Labels
easy topic-2to3 type-bug An unexpected behavior, bug, or error

Comments

@tebeka
Copy link
Mannequin

tebeka mannequin commented Apr 7, 2011

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']

    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented Apr 7, 2011

    The following code is not changed by 2to3::

    import os
    reload(os)
    

    reload has moved to the imp module.

    @tebeka tebeka mannequin added the topic-2to3 label Apr 7, 2011
    @rhettinger
    Copy link
    Contributor

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

    @rhettinger rhettinger added easy type-bug An unexpected behavior, bug, or error labels Apr 7, 2011
    @BluePeppers
    Copy link
    Mannequin

    BluePeppers mannequin commented Apr 7, 2011

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

    @tebeka
    Copy link
    Mannequin Author

    tebeka mannequin commented Apr 7, 2011

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

    @rhettinger
    Copy link
    Contributor

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

    @Bluehorn
    Copy link
    Mannequin

    Bluehorn mannequin commented Jun 14, 2011

    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.

    @merwok
    Copy link
    Member

    merwok commented Jul 26, 2011

    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.

    @birkenfeld
    Copy link
    Member

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

    @BluePeppers
    Copy link
    Mannequin

    BluePeppers mannequin commented Jul 30, 2011

    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.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Nov 4, 2012

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

    @merwok
    Copy link
    Member

    merwok commented Nov 4, 2012

    FixIntern → FixReload

    @merwok
    Copy link
    Member

    merwok commented Nov 4, 2012

    More importantly, tests would be great.

    @berkerpeksag
    Copy link
    Member

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

    @benjaminp
    Copy link
    Contributor

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

    @berkerpeksag
    Copy link
    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 8, 2012

    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

    @python-dev python-dev mannequin closed this as completed Dec 8, 2012
    @bitdancer
    Copy link
    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?

    @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
    easy topic-2to3 type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants