classification
Title: Bad use of `self` in importlib
Type: crash Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.snow Nosy List: brett.cannon, christian.heimes, cool-RR, eric.snow, haypo, python-dev
Priority: normal Keywords: patch

Created on 2013-12-30 20:26 by cool-RR, last changed 2014-01-03 05:39 by eric.snow. This issue is now closed.

Files
File name Uploaded Description Edit
issue20097-tests.diff eric.snow, 2014-01-02 03:17 review
Messages (10)
msg207105 - (view) Author: Ram Rachum (cool-RR) * Date: 2013-12-30 20:26
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.
msg207106 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-12-30 20:29
I don't see a class method at line 1431.
msg207107 - (view) Author: Ram Rachum (cool-RR) * Date: 2013-12-30 20:32
Sorry, bad link, this is the right link:

http://hg.python.org/cpython/file/fd846837492d/Lib/importlib/_bootstrap.py#l1409
msg207110 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-12-30 20:40
Thanks! :)
msg207143 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-01-02 03:09
Here's a patch with tests that cover find_module() and find_spec() for WindowsRegistryFinder (the missing case) and fixes the bug.
msg207144 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-01-02 03:12
The patch passes on my linux box and on my windows 7 laptop (using Visual Studio 2010 Express).
msg207145 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-01-02 03:17
Here's an updated patch that fixes as copy-and-paste mistake.
msg207199 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2014-01-03 02:15
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)
msg207206 - (view) Author: Roundup Robot (python-dev) Date: 2014-01-03 05:32
New changeset 7dbb4c6cd30e by Eric Snow in branch 'default':
Issue #20097: Fix bad use of "self" in importlib's WindowsRegistryFinder.
http://hg.python.org/cpython/rev/7dbb4c6cd30e
msg207208 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-01-03 05:39
Thanks for the review, Victor.  As to that note, it is the subject of issue #19714.
History
Date User Action Args
2014-01-03 05:39:24eric.snowsetstatus: open -> closed
messages: + msg207208

assignee: brett.cannon -> eric.snow
dependencies: - Add tests for importlib.machinery.WindowsRegistryFinder
resolution: fixed
stage: patch review -> resolved
2014-01-03 05:32:00python-devsetnosy: + python-dev
messages: + msg207206
2014-01-03 02:15:56hayposetnosy: + haypo
messages: + msg207199
2014-01-02 03:17:37eric.snowsetfiles: + issue20097-tests.diff

messages: + msg207145
2014-01-02 03:16:56eric.snowsetfiles: - issue20097-tests.diff
2014-01-02 03:12:27eric.snowsetmessages: + msg207144
2014-01-02 03:09:07eric.snowsetfiles: + issue20097-tests.diff

nosy: + eric.snow
messages: + msg207143

keywords: + patch
stage: test needed -> patch review
2013-12-30 22:05:31brett.cannonsetdependencies: + Add tests for importlib.machinery.WindowsRegistryFinder
2013-12-30 22:04:51brett.cannonsetstage: needs patch -> test needed
2013-12-30 20:40:47christian.heimessetnosy: + brett.cannon
messages: + msg207110

assignee: brett.cannon
stage: needs patch
2013-12-30 20:32:27cool-RRsetmessages: + msg207107
2013-12-30 20:29:38christian.heimessetnosy: + christian.heimes
messages: + msg207106
2013-12-30 20:26:41cool-RRcreate