| Index: client/utils/zip_package.py
|
| diff --git a/client/utils/zip_package.py b/client/utils/zip_package.py
|
| index 49dc89054ffb7ac6940ae1cdfef27d3370fd31f0..539709b1c8106835e5ee06bd656bbc07b7dfd9fc 100755
|
| --- a/client/utils/zip_package.py
|
| +++ b/client/utils/zip_package.py
|
| @@ -35,6 +35,18 @@ _extracted_files = []
|
| _extracted_files_lock = threading.Lock()
|
|
|
|
|
| +# Patch zipimport.zipimporter hook to accept unicode strings
|
| +def zipimporter_unicode(archivepath):
|
| + if isinstance(archivepath, unicode):
|
| + archivepath = archivepath.encode(sys.getfilesystemencoding())
|
| + return zipimport.zipimporter(archivepath)
|
| +
|
| +
|
| +for i, hook in enumerate(sys.path_hooks):
|
| + if hook is zipimport.zipimporter:
|
| + sys.path_hooks[i] = zipimporter_unicode
|
| +
|
| +
|
| class ZipPackageError(RuntimeError):
|
| """Failed to create a zip package."""
|
|
|
| @@ -238,7 +250,13 @@ def get_main_script_path():
|
| """
|
| # If running from interactive console __file__ is not defined.
|
| main = sys.modules['__main__']
|
| - return get_module_zip_archive(main) or getattr(main, '__file__', None)
|
| + path = get_module_zip_archive(main)
|
| + if path:
|
| + return path
|
| +
|
| + path = getattr(main, '__file__', None)
|
| + if path:
|
| + return path.decode(sys.getfilesystemencoding())
|
|
|
|
|
| def _write_temp_data(name, data, temp_dir):
|
| @@ -279,7 +297,8 @@ def extract_resource(package, resource, temp_dir=None):
|
| # For regular non-zip packages just construct an absolute path.
|
| if not is_zipped_module(package):
|
| # Package's __file__ attribute is always an absolute path.
|
| - path = os.path.join(os.path.dirname(package.__file__),
|
| + ppath = package.__file__.decode(sys.getfilesystemencoding())
|
| + path = os.path.join(os.path.dirname(ppath),
|
| resource.replace('/', os.sep))
|
| if not os.path.exists(path):
|
| raise ValueError('No such resource in %s: %s' % (package, resource))
|
|
|