Title: pkgutil importlib migration test was failing on Windows buildbots
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.3
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, db3l, georg.brandl, ncoghlan
Priority: normal Keywords:

Created on 2012-07-18 10:46 by ncoghlan, last changed 2012-07-20 01:17 by ncoghlan. This issue is now closed.

Messages (4)
msg165752 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-07-18 10:46
As noted in #15314, one of the pkgutil tests was failing on Windows because pkgutil.get_importer("") was returning None. On my Fedora system it returns FileFinder(".").

I've now tweaked that particular test to use a bogus path string so that None is the expected result on all platforms.

However, the cross-platform discrepancy is a little disturbing - I would have expected the operation to either fail or succeed regardless of platform.

Since pkgutil.get_importer is now just a wrapper that takes care of checking path_importer_cache and then walking sys.path_hooks, I believe the actual culprit is FileFinder.path_hook()("") returning None (I'm currently downloading and installing 3.3b1 on my gaming machine to confirm that)
msg165758 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-07-18 11:50
Well, that's weird. A manual test on my Windows 7 gaming rig indicates that the old test *should* have worked on Windows as well.

I have no idea how to investigate this further. David, are you able to check what pkgutil.get_importer("") returns when running locally on your Windows buildbots?

An example of the error the buildbots were getting:
msg165797 - (view) Author: David Bolen (db3l) * Date: 2012-07-18 20:27
With a local build on my buildbot of the tip of the default branch, pkgutil.get_importer('') returns FileFilter('.').  The tests also passed.

However, after checking here and realizing the offending code had been removed from the test, I put it back in and it still fails.

I think the problem is that sys.path[0] is not '' when testing in the buildbot environment (though it is when I run the debug interpreter interactively).  Within the buildbot scripts it's a path to the stdlib test zip, so for example in my test tree it's "D:\cygwin\home\db3l\test\build\PCbuild\".

And if I hand that string to pkgutil.get_importer() I do seem to get None back.
msg165894 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-07-20 01:17
Ah, that makes sense - since the zip file doesn't exist on buildbots, returning None is the correct result.

Mystery explained, thanks :)
Date User Action Args
2012-07-20 01:17:20ncoghlansetstatus: open -> closed
resolution: not a bug
messages: + msg165894

title: pkgutil.get_importer("") was returning None on Windows buildbots -> pkgutil importlib migration test was failing on Windows buildbots
2012-07-18 20:27:02db3lsetmessages: + msg165797
2012-07-18 11:50:26ncoghlansetnosy: + db3l

messages: + msg165758
title: FileFinder.path_hook()("") returns None on Windows -> pkgutil.get_importer("") was returning None on Windows buildbots
2012-07-18 10:48:43ncoghlansettype: behavior
stage: test needed
2012-07-18 10:46:02ncoghlancreate