Skip to content

Commit

Permalink
Different zip usage to support py3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
facundobatista committed Feb 18, 2021
1 parent aad9797 commit 404d42a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charmcraft/commands/store/__init__.py
Expand Up @@ -250,7 +250,7 @@ def run(self, parsed_args):
def get_name_from_zip(filepath):
"""Get the charm/bundle name from a zip file."""
try:
zf = zipfile.ZipFile(filepath)
zf = zipfile.ZipFile(str(filepath))
except zipfile.BadZipFile:
raise CommandError("Cannot open {!r} (bad zip file).".format(str(filepath)))

Expand Down
5 changes: 2 additions & 3 deletions tests/commands/test_store_commands.py
Expand Up @@ -313,11 +313,10 @@ def test_list_registered_several(caplog, store_mock, config):

def _build_zip_with_yaml(zippath, filename, *, content=None, raw_yaml=None):
"""Create a yaml named 'filename' with given content, inside a zip file in 'zippath'."""
zf = zipfile.ZipFile(zippath, 'w')
if raw_yaml is None:
raw_yaml = yaml.dump(content).encode('ascii')
with zf.open(filename, 'w') as fh:
fh.write(raw_yaml)
with zipfile.ZipFile(str(zippath), 'w') as zf:
zf.writestr(filename, raw_yaml)


def test_get_name_bad_zip(tmp_path):
Expand Down

0 comments on commit 404d42a

Please sign in to comment.