Skip to content

Commit

Permalink
Replace open() built-in with io.open() on binaries for code consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
RaptDept committed Aug 11, 2018
1 parent 52825c6 commit 5a4bfee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion poetry/masonry/builders/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import contextlib
import hashlib
import io
import os
import re
import tempfile
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion poetry/repositories/legacy_repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cgi
import io
import re

try:
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import io
import os
import re
import tarfile
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5a4bfee

Please sign in to comment.