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

Bad use of self in importlib #64296

Closed
cool-RR mannequin opened this issue Dec 30, 2013 · 10 comments
Closed

Bad use of self in importlib #64296

cool-RR mannequin opened this issue Dec 30, 2013 · 10 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@cool-RR
Copy link
Mannequin

cool-RR mannequin commented Dec 30, 2013

BPO 20097
Nosy @brettcannon, @vstinner, @tiran, @cool-RR, @ericsnowcurrently
Files
  • issue20097-tests.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/ericsnowcurrently'
    closed_at = <Date 2014-01-03.05:39:24.544>
    created_at = <Date 2013-12-30.20:26:41.975>
    labels = ['library', 'type-crash']
    title = 'Bad use of `self` in importlib'
    updated_at = <Date 2014-01-03.05:39:24.542>
    user = 'https://github.com/cool-RR'

    bugs.python.org fields:

    activity = <Date 2014-01-03.05:39:24.542>
    actor = 'eric.snow'
    assignee = 'eric.snow'
    closed = True
    closed_date = <Date 2014-01-03.05:39:24.544>
    closer = 'eric.snow'
    components = ['Library (Lib)']
    creation = <Date 2013-12-30.20:26:41.975>
    creator = 'cool-RR'
    dependencies = []
    files = ['33295']
    hgrepos = []
    issue_num = 20097
    keywords = ['patch']
    message_count = 10.0
    messages = ['207105', '207106', '207107', '207110', '207143', '207144', '207145', '207199', '207206', '207208']
    nosy_count = 6.0
    nosy_names = ['brett.cannon', 'vstinner', 'christian.heimes', 'cool-RR', 'python-dev', 'eric.snow']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue20097'
    versions = ['Python 3.4']

    @cool-RR
    Copy link
    Mannequin Author

    cool-RR mannequin commented Dec 30, 2013

    There's a bad usage of self here:

    http://hg.python.org/cpython/file/fd846837492d/Lib/importlib/_bootstrap.py#l1431
    

    self isn't defined because it's a class method.

    @cool-RR cool-RR mannequin added stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump labels Dec 30, 2013
    @tiran
    Copy link
    Member

    tiran commented Dec 30, 2013

    I don't see a class method at line 1431.

    @cool-RR
    Copy link
    Mannequin Author

    cool-RR mannequin commented Dec 30, 2013

    Sorry, bad link, this is the right link:

    http://hg.python.org/cpython/file/fd846837492d/Lib/importlib/_bootstrap.py#l1409

    @tiran
    Copy link
    Member

    tiran commented Dec 30, 2013

    Thanks! :)

    @ericsnowcurrently
    Copy link
    Member

    Here's a patch with tests that cover find_module() and find_spec() for WindowsRegistryFinder (the missing case) and fixes the bug.

    @ericsnowcurrently
    Copy link
    Member

    The patch passes on my linux box and on my windows 7 laptop (using Visual Studio 2010 Express).

    @ericsnowcurrently
    Copy link
    Member

    Here's an updated patch that fixes as copy-and-paste mistake.

    @vstinner
    Copy link
    Member

    vstinner commented Jan 3, 2014

    Would it be possible to put @unittest.skipUnless(...) on WindowsRegistryFinderTests instead of duplicating it?

    Except of this nit, the patch looks good to me.

    Note: WindowsRegistryFinder.find_spec() contains the comment:

    # XXX untested! Need a Windows person to write tests (otherwise mock out appropriately)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 3, 2014

    New changeset 7dbb4c6cd30e by Eric Snow in branch 'default':
    Issue bpo-20097: Fix bad use of "self" in importlib's WindowsRegistryFinder.
    http://hg.python.org/cpython/rev/7dbb4c6cd30e

    @ericsnowcurrently
    Copy link
    Member

    Thanks for the review, Victor. As to that note, it is the subject of issue bpo-19714.

    @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
    stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants