Issue #383 resolved

Namespace-related TypeError with Python 3.3

Virgil Dupras avatarVirgil Dupras created an issue

This is very much related to #240, but not quite because it has nothing to do with namespace packages.

I started adding an import-wrapped-in-ImportError (an import that graciously fail if the module doesn't exist) in my project which runs under Python 3.3, and when I run my tests, I get a TypeError: '_NamespacePath' object does not support indexing, exactly like in #373.

I've partially applied the patch from #240 and it fixes the problem. I'll submit a pull request in a few minutes.

Comments (3)

  1. holger krekel

    Fix TypeError crash on failed imports under py3.3.

    Starting with Python 3.3, NamespacePath passed to importlib hooks seem to have lost the ability to be accessed by index.

    We wrap the index access in a try..except and wrap the path in a list if it happens.

    Fixes #383.

    → <<cset dac4900b78f2>>

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.