Skip to content

Commit df964f3

Browse files
author
Signal Linden
authored
Merge pull request #26 from secondlife/signal/py37
Fix py37 support
2 parents ec4ced3 + f6dc482 commit df964f3

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
1515
python-version: ["3.11"]
1616
include:
17+
- os: ubuntu-latest
18+
python-version: "3.7"
1719
- os: ubuntu-latest
1820
python-version: "3.8"
1921
- os: ubuntu-latest

autobuild/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,12 @@ def compute_hash(path: str, hash: Callable[[], hashlib._Hash]):
326326
Compute a hash for a file effeciently by streaming it into the hash algorithm
327327
"""
328328
h = hash()
329-
b = bytearray(128*1024)
330-
mv = memoryview(b)
331329
try:
332330
with open(path, 'rb') as f:
333-
while n := f.readinto(mv):
334-
h.update(mv[:n])
331+
chunk = f.read(8192)
332+
while chunk:
333+
h.update(chunk)
334+
chunk = f.read(8192)
335335
return h.hexdigest()
336336
except IOError as err:
337337
raise AutobuildError(f"Can't compute {h.name} for {path}: {err}")

tests/test_install.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,8 @@ def test_download(self, mock_urlopen: MagicMock):
751751
with envvar("AUTOBUILD_GITHUB_TOKEN", None):
752752
autobuild_tool_install.download_package("https://example.org/foo.tar.bz2")
753753
mock_urlopen.assert_called()
754-
got_req = mock_urlopen.mock_calls[0].args[0]
754+
_, args, _ = mock_urlopen.mock_calls[0]
755+
got_req = args[0]
755756
self.assertIsNone(got_req.unredirected_hdrs.get("Authorization"))
756757

757758
@patch("urllib.request.urlopen")
@@ -760,7 +761,8 @@ def test_download_github(self, mock_urlopen: MagicMock):
760761
with envvar("AUTOBUILD_GITHUB_TOKEN", "token-123"):
761762
autobuild_tool_install.download_package("https://example.org/foo.tar.bz2", creds="github")
762763
mock_urlopen.assert_called()
763-
got_req = mock_urlopen.mock_calls[0].args[0]
764+
_, args, _ = mock_urlopen.mock_calls[0]
765+
got_req = args[0]
764766
self.assertEqual(got_req.unredirected_hdrs["Authorization"], "Bearer token-123")
765767
self.assertEqual(got_req.unredirected_hdrs["Accept"], "application/octet-stream")
766768

@@ -770,7 +772,8 @@ def test_download_gitlab(self, mock_urlopen: MagicMock):
770772
with envvar("AUTOBUILD_GITLAB_TOKEN", "token-123"):
771773
autobuild_tool_install.download_package("https://example.org/foo.tar.bz2", creds="gitlab")
772774
mock_urlopen.assert_called()
773-
got_req = mock_urlopen.mock_calls[0].args[0]
775+
_, args, _ = mock_urlopen.mock_calls[0]
776+
got_req = args[0]
774777
self.assertEqual(got_req.unredirected_hdrs["Authorization"], "Bearer token-123")
775778

776779
@patch("urllib.request.urlopen")

0 commit comments

Comments
 (0)