diff --git a/poetry/masonry/builders/wheel.py b/poetry/masonry/builders/wheel.py index d920294bfb4..bc83050e952 100644 --- a/poetry/masonry/builders/wheel.py +++ b/poetry/masonry/builders/wheel.py @@ -2,6 +2,7 @@ import contextlib import hashlib +import io import os import re import tempfile @@ -233,7 +234,7 @@ def _add_file(self, wheel, full_path, rel_path): zinfo.external_attr |= 0x10 # MS-DOS directory flag hashsum = hashlib.sha256() - with open(full_path, "rb") as src: + with io.open(full_path, "rb") as src: while True: buf = src.read(1024 * 8) if not buf: diff --git a/poetry/repositories/legacy_repository.py b/poetry/repositories/legacy_repository.py index d8c16242e3b..72c38b74332 100644 --- a/poetry/repositories/legacy_repository.py +++ b/poetry/repositories/legacy_repository.py @@ -1,4 +1,5 @@ import cgi +import io import re try: @@ -341,7 +342,7 @@ def _get_release_info(self, name, version): # type: (str, str) -> dict def _download(self, url, dest): # type: (str, str) -> None r = self._session.get(url, stream=True) - with open(dest, "wb") as f: + with io.open(dest, "wb") as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) diff --git a/poetry/repositories/pypi_repository.py b/poetry/repositories/pypi_repository.py index 990d8b12f59..756366c3279 100644 --- a/poetry/repositories/pypi_repository.py +++ b/poetry/repositories/pypi_repository.py @@ -1,4 +1,5 @@ import logging +import io import os import re import tarfile @@ -512,7 +513,7 @@ def _inspect_sdist_with_setup(self, sdist_dir): def _download(self, url, dest): # type: (str, str) -> None r = get(url, stream=True) - with open(dest, "wb") as f: + with io.open(dest, "wb") as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk)