Merge ~twom/launchpad:oci-fileno-error-on-upload into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 076490b97814a1b5c3ce899da8d9a04c0c417a49
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:oci-fileno-error-on-upload
Merge into: launchpad:master
Diff against target: 15 lines (+4/-0)
1 file modified
lib/lp/oci/model/ociregistryclient.py (+4/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+399644@code.launchpad.net

Commit message

Workaround requests handling of extract tar files

Description of the change

Requests doesn't like extracted tar files, as they have a 'fileno' attribute, but accessing it causes an error.
Upstream requests PR is here: https://github.com/psf/requests/pull/5239

For now, just give the layer object a len (set to tarfile.size).

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/oci/model/ociregistryclient.py b/lib/lp/oci/model/ociregistryclient.py
2index 1a9be6c..f1e083b 100644
3--- a/lib/lp/oci/model/ociregistryclient.py
4+++ b/lib/lp/oci/model/ociregistryclient.py
5@@ -167,6 +167,10 @@ class OCIRegistryClient:
6 if tarinfo.name != 'layer.tar':
7 continue
8 fileobj = un_zipped.extractfile(tarinfo)
9+ # XXX Work around requests handling of objects that have
10+ # fileno, but error on access in python3:
11+ # https://github.com/psf/requests/pull/5239
12+ fileobj.len = tarinfo.size
13 try:
14 cls._upload(
15 digest, push_rule, fileobj, tarinfo.size,

Subscribers

People subscribed via source and target branches

to status/vote changes: