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

fixer for sys.exitfunc -> atexit #46609

Closed
brettcannon opened this issue Mar 17, 2008 · 13 comments
Closed

fixer for sys.exitfunc -> atexit #46609

brettcannon opened this issue Mar 17, 2008 · 13 comments
Assignees
Labels
topic-2to3 type-feature A feature request or enhancement

Comments

@brettcannon
Copy link
Member

BPO 2356
Nosy @brettcannon, @avassalotti, @benjaminp, @mitsuhiko
Files
  • atexit_fixer.patch
  • fix_exitfunc.diff
  • sys_exitfunc_warning.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 2010-03-20.16:13:02.112>
    created_at = <Date 2008-03-17.19:37:31.570>
    labels = ['type-feature', 'expert-2to3']
    title = 'fixer for sys.exitfunc -> atexit'
    updated_at = <Date 2010-03-20.16:13:02.111>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2010-03-20.16:13:02.111>
    actor = 'benjamin.peterson'
    assignee = 'benjamin.peterson'
    closed = True
    closed_date = <Date 2010-03-20.16:13:02.112>
    closer = 'benjamin.peterson'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2008-03-17.19:37:31.570>
    creator = 'brett.cannon'
    dependencies = []
    files = ['11252', '12279', '14453']
    hgrepos = []
    issue_num = 2356
    keywords = ['patch', 'needs review']
    message_count = 13.0
    messages = ['63731', '63746', '71602', '71642', '71666', '71668', '71670', '71950', '77299', '90146', '101358', '101359', '101376']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'collinwinter', 'jafo', 'alexandre.vassalotti', 'benjamin.peterson', 'aronacher']
    pr_nums = []
    priority = 'critical'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue2356'
    versions = ['Python 2.6']

    @brettcannon
    Copy link
    Member Author

    sys.exitfunc should raise a Py3K warning when set/used.

    @brettcannon brettcannon added release-blocker interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 17, 2008
    @brettcannon
    Copy link
    Member Author

    A fixer to use the atexit module is needed.

    @brettcannon
    Copy link
    Member Author

    Actually, a fixer probably won't work since that would require the
    atexit module to be imported.

    @benjaminp
    Copy link
    Contributor

    This is going to be very hard to implement without module descriptors.
    It might be better to make a 2to3 fixer which inserts an import too.

    @brettcannon
    Copy link
    Member Author

    On Thu, Aug 21, 2008 at 6:43 AM, Benjamin Peterson
    <report@bugs.python.org> wrote:

    Benjamin Peterson <musiccomposition@gmail.com> added the comment:

    This is going to be very hard to implement without module descriptors.
    It might be better to make a 2to3 fixer which inserts an import too.

    So for every sys import you are going to add an "import atexit"? That
    doesn't seem reasonable. And if the call is in an expression context
    you definitely cannot add the import.

    @benjaminp
    Copy link
    Contributor

    On Thu, Aug 21, 2008 at 1:21 PM, Brett Cannon <report@bugs.python.org> wrote:

    So for every sys import you are going to add an "import atexit"? That
    doesn't seem reasonable. And if the call is in an expression context
    you definitely cannot add the import.

    You're right; it's not going to be perfect, but 2to3 could warn when
    it couldn't insert the import statement.


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue2356\>


    @brettcannon
    Copy link
    Member Author

    On Thu, Aug 21, 2008 at 11:45 AM, Benjamin Peterson
    <report@bugs.python.org> wrote:

    Benjamin Peterson <musiccomposition@gmail.com> added the comment:

    On Thu, Aug 21, 2008 at 1:21 PM, Brett Cannon <report@bugs.python.org> wrote:
    >
    > So for every sys import you are going to add an "import atexit"? That
    > doesn't seem reasonable. And if the call is in an expression context
    > you definitely cannot add the import.

    You're right; it's not going to be perfect, but 2to3 could warn when
    it couldn't insert the import statement.
    >

    OK, I can live with that.

    @benjaminp
    Copy link
    Contributor

    Here's my 2to3 fixer for the cause. It always changes assignment to
    sys.exitfunc to atexit.register. It then inserts a "import atexit" after
    the module's sys import. If it can't find a sys import (that should be
    rare obviously :) ), it emits a warning.

    @benjaminp benjaminp added topic-2to3 and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Aug 25, 2008
    @benjaminp benjaminp changed the title sys.exitfunc should raise a Py3K warning fixer for sys.exitfunc -> atexit Aug 25, 2008
    @benjaminp benjaminp added the type-feature A feature request or enhancement label Aug 25, 2008
    @mitsuhiko
    Copy link
    Member

    Since yesterday there is a handy little helper that adds imports to
    files which is already used for the reduce() / intern() fixers. This
    makes this fix a lot easier.

    I attached a version that does that.

    However the import adder is not yet as sophisticated as the one in the
    previous patch, but the utility method could be improved to better adapt
    to existing styleguides.

    @avassalotti
    Copy link
    Member

    Here is an attempt to add a Py3K warning when sys.exitfunc is modified.

    @jafo
    Copy link
    Mannequin

    jafo mannequin commented Mar 20, 2010

    I've posted to python-dev asking for a reviewer for this, the thread is at http://mail.python.org/pipermail/python-dev/2010-March/098597.html

    @benjaminp
    Copy link
    Contributor

    Sean, are you referring to the warning or the 2to3 fixer?

    @benjaminp benjaminp assigned benjaminp and unassigned collinwinter Mar 20, 2010
    @benjaminp
    Copy link
    Contributor

    Committed the 2to3 fixer in r79137.

    @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
    topic-2to3 type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants