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

'exceptions' import fixer #46603

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

'exceptions' import fixer #46603

brettcannon opened this issue Mar 17, 2008 · 11 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-2to3 type-feature A feature request or enhancement

Comments

@brettcannon
Copy link
Member

BPO 2350
Nosy @loewis, @brettcannon, @jcea, @cjmayo, @benjaminp, @berkerpeksag, @iritkatriel
Superseder
  • bpo-45544: Close 2to3 issues and list them here
  • Files
  • exceptions_fixer.patch
  • issue2350.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 = None
    closed_at = <Date 2021-10-20.23:05:39.072>
    created_at = <Date 2008-03-17.19:22:08.317>
    labels = ['3.8', 'type-feature', 'expert-2to3', '3.9', '3.10']
    title = "'exceptions' import fixer"
    updated_at = <Date 2021-10-20.23:05:39.072>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2021-10-20.23:05:39.072>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.23:05:39.072>
    closer = 'iritkatriel'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2008-03-17.19:22:08.317>
    creator = 'brett.cannon'
    dependencies = []
    files = ['11251', '28494']
    hgrepos = []
    issue_num = 2350
    keywords = []
    message_count = 11.0
    messages = ['63718', '63769', '71886', '71902', '71949', '72971', '172772', '172773', '178590', '178591', '379318']
    nosy_count = 9.0
    nosy_names = ['loewis', 'brett.cannon', 'collinwinter', 'jcea', 'cjmayo', 'benjamin.peterson', 'douglas', 'berker.peksag', 'iritkatriel']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45544'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue2350'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @brettcannon
    Copy link
    Member Author

    Importing 'exceptions' should raise at least a Py3K warning, if not a
    full DeprecationWarning.

    @douglas
    Copy link
    Mannequin

    douglas mannequin commented Mar 17, 2008

    I ran python through a debugger and found that the exceptions module is
    imported automatically at load time. Because of this, when "import
    exceptions" is parsed, the module is already loaded, and PyImport_Import
    is not called. In order to correct this, we'll have to either catch
    this at the AST, or just handle it in 2to3...

    @benjaminp
    Copy link
    Contributor

    I'm not sure how we could implement a warning on import of exceptions
    aside from implementing it in the compiler. I suppose 2to3 could just
    remove the import...

    @brettcannon
    Copy link
    Member Author

    On Sun, Aug 24, 2008 at 2:51 PM, Benjamin Peterson
    <report@bugs.python.org> wrote:

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

    I'm not sure how we could implement a warning on import of exceptions
    aside from implementing it in the compiler. I suppose 2to3 could just
    remove the import...

    ... and would also have to change all references. But that would
    probably work out fine.

    @benjaminp
    Copy link
    Contributor

    Here's my 2to3 fixer for the job. It cleanly removes the imports and
    changes the usage.

    @benjaminp benjaminp changed the title Warn against importing 'exceptions' 'exceptions' import fixer Aug 25, 2008
    @benjaminp benjaminp added the type-feature A feature request or enhancement label Aug 25, 2008
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Sep 10, 2008

    Given that this is now a request for a fixer, and not a request for a
    deprecation warning, I don't see why this is considered a release
    blocker. Lowering the priority to normal. Even if the fixer isn't added
    to the 2to3 copy shipped with 2.6.0, I think 2to3 improvements can well
    be incorporated into 2.6.1 (including additional fixers).

    @loewis loewis mannequin removed the release-blocker label Sep 10, 2008
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Oct 12, 2012

    Brett: Why did you close the issue? Benjamin's change was never committed...

    @brettcannon
    Copy link
    Member Author

    I don't remember.

    @brettcannon brettcannon reopened this Oct 12, 2012
    @berkerpeksag
    Copy link
    Member

    I've converted Benjamin's patch to extended diff format, fixed some
    PEP-8 violations and typos, removed the {get, set}_prefix usage, added
    more tests and updated the documentation.

    @benjaminp
    Copy link
    Contributor

    This is something people can easily convert in there 2.x code, so I don't think the need for it is great.

    @iritkatriel
    Copy link
    Member

    Updating the versions, though it seems that you may want to close this as rejected based on the discussion.

    @iritkatriel iritkatriel added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels Oct 22, 2020
    @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
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-2to3 type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants