Fix missing mode property on file wrapper

Without this property, uploads using `requests` fails to set the
Content-Length header, and falls back to chunked encoding,
which many hosts (e.g. S3) don't support.
This commit is contained in:
oefe 2022-08-27 17:08:29 +02:00
parent e2716d3cd0
commit f8b536ca06
4 changed files with 7 additions and 0 deletions

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458
- Fix missing `mode` property on file wrapper breaking uploads via `requests`
## [12.5.2] - 2022-07-18

View File

@ -28,6 +28,7 @@ The following people have contributed to the development of Rich:
- [Paul McGuire](https://github.com/ptmcg)
- [Antony Milne](https://github.com/AntonyMilneQB)
- [Michael Milton](https://github.com/multimeric)
- [Martina Oefelein](https://github.com/oefe)
- [Nathan Page](https://github.com/nathanrpage97)
- [Avi Perl](https://github.com/avi-perl)
- [Laurent Peuch](https://github.com/psycojoker)

View File

@ -216,6 +216,10 @@ class _Reader(RawIOBase, BinaryIO):
def isatty(self) -> bool:
return self.handle.isatty()
@property
def mode(self) -> str:
return self.handle.mode
@property
def name(self) -> str:
return self.handle.name

View File

@ -614,6 +614,7 @@ def test_wrap_file() -> None:
with open(filename, "rb") as file:
with rich.progress.wrap_file(file, total=total) as f:
assert f.read() == b"Hello, World!"
assert f.mode == "rb"
assert f.name == filename
assert f.closed
assert not f.handle.closed