| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4d00329 commit 2d06f66
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ | |||
| 25 | 25 | import os | |
| 26 | 26 | import sys | |
| 27 | 27 | ||
| 28 | + py3 = sys.version_info[:2] >= (3, 0) | ||
| 28 | 29 | ||
| 29 | 30 | # The cached list of all known modules | |
| 30 | 31 | modules = set() | |
@@ -107,6 +108,10 @@ def find_modules(path): | |||
| 107 | 108 | fo, pathname, _ = imp.find_module(name, [path]) | |
| 108 | 109 | except (ImportError, SyntaxError): | |
| 109 | 110 | continue | |
| 111 | + except UnicodeEncodeError: | ||
| 112 | + # Happens with Python 3 when there is a filename in some | ||
| 113 | + # invalid encoding | ||
| 114 | + continue | ||
| 110 | 115 | else: | |
| 111 | 116 | if fo is not None: | |
| 112 | 117 | fo.close() | |
@@ -129,6 +134,12 @@ def find_all_modules(path=None): | |||
| 129 | 134 | if not p: | |
| 130 | 135 | p = os.curdir | |
| 131 | 136 | for module in find_modules(p): | |
| 137 | + if not py3 and not isinstance(module, unicode): | ||
| 138 | + try: | ||
| 139 | + module = module.decode(sys.getfilesystemencoding()) | ||
| 140 | + except UnicodeDecodeError: | ||
| 141 | + # Not importable anyway, ignore it | ||
| 142 | + continue | ||
| 132 | 143 | modules.add(module) | |
| 133 | 144 | yield | |
| 134 | 145 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments