From ad2164bd2f55fd3610c7bdc8414f792a1580f796 Mon Sep 17 00:00:00 2001 From: Ed Lewis Date: Mon, 19 Sep 2016 10:52:27 +0100 Subject: [PATCH 1/2] Ensure zip filenames are UTF-8 (closes #94) --- gordon/resources/lambdas.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gordon/resources/lambdas.py b/gordon/resources/lambdas.py index ec8b50f..691e853 100644 --- a/gordon/resources/lambdas.py +++ b/gordon/resources/lambdas.py @@ -472,6 +472,9 @@ def get_zip_file(self): for filename in files: source = os.path.join(destination, basedir, filename) relative_destination = os.path.join(relative, filename) + if six.PY2: + source = source.decode('utf-8', errors='strict') + relative_destination = relative_destination.decode('utf-8', errors='strict') zf.write(source, relative_destination) tmp.seek(0) From 879a1c1e8b47fa88d036a7b72bc767dfb9a2d6d6 Mon Sep 17 00:00:00 2001 From: Ed Lewis Date: Mon, 19 Sep 2016 10:56:17 +0100 Subject: [PATCH 2/2] Switch to ZIP_DEFLATED (closes #61) --- gordon/resources/lambdas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gordon/resources/lambdas.py b/gordon/resources/lambdas.py index 691e853..75908fc 100644 --- a/gordon/resources/lambdas.py +++ b/gordon/resources/lambdas.py @@ -466,7 +466,7 @@ def get_zip_file(self): raise exceptions.LambdaBuildProcessError(exc, self) with tempfile.SpooledTemporaryFile(0, 'wb') as tmp: - with zipfile.ZipFile(tmp, 'w') as zf: + with zipfile.ZipFile(tmp, 'w', zipfile.ZIP_DEFLATED) as zf: for basedir, dirs, files in os.walk(destination): relative = os.path.relpath(basedir, destination) for filename in files: