Skip to content

Commit

Permalink
fix TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
u committed Jan 12, 2025
1 parent 8b8691a commit 40b6853
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py2pack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import zipfile
from packaging.requirements import Requirement
from os.path import basename
from io import StringIO


try:
Expand Down Expand Up @@ -122,15 +123,15 @@ def pypi_archive_file_tar(file_path):
with tarfile.open(file_path, 'r') as archive:
for member in archive.getmembers():
if os.path.basename(member.name) == 'PKG-INFO':
return pypi_text_stream(archive.extractfile(member))
return pypi_text_stream(StringIO(archive.extractfile(member).read().decode()))
raise KeyError('PKG-INFO not found on archive '+file_path)


def pypi_archive_file_zip(file_path):
with zipfile.ZipFile(file_path, 'r') as archive:
for member in archive.namelist():
if os.path.basename(member) == 'PKG-INFO':
return pypi_text_stream(archive.open(member))
return pypi_text_stream(StringIO(archive.open(member).read().decode()))
raise KeyError('PKG-INFO not found on archive '+file_path)


Expand Down

0 comments on commit 40b6853

Please sign in to comment.