Skip to content

StreamingBody.__enter__ should return self #3564

@dizel3d

Description

@dizel3d

Describe the bug

f = s3_client.get_object(...)["Body"]  # f is StreamingBody object
f.read()  # At the end of the stream this will check content-length and raise an error if mismatch
f.close()

is not equal to

with s3_client.get_object(...)["Body"] as f:  # f is NOT StreamingBody object
  f.read()  # This will NOT check content-length

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The problem is in StreamingBody.enter. I believe it should return self instead of self._raw_stream.

Current Behavior

StreamingBody.__enter__ returns self._raw_stream instead of self.

Reproduction Steps

See description.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

1.40.34

Environment details (OS name and version, etc.)

Python 3.10.12

Metadata

Metadata

Assignees

Labels

bugThis issue is a confirmed bug.p3This is a minor priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions