Repository navigation
HTTPX Bug Report #3810
Replies: 1 comment 3 replies
|
I reproduced the missing exception on Windows 11 with Python 3.15.1, using HTTPX source at The distinguishing factor appears to be the temporary-file wrapper, rather than an empty file: import io
import tempfile
with tempfile.TemporaryFile(mode="w") as upload:
print(type(upload).__name__, isinstance(upload, io.TextIOBase))
print(type(upload.file).__name__, isinstance(upload.file, io.TextIOBase))On this Windows environment, the first line reports The
For regression coverage, explicitly using I cannot speak for the maintainers about accepting a PR, but these results narrow down the behavior your proposed change would need to cover. |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone! I ran the test suite on Windows with Python 3.13 and found a failing test case in test_multipart.py. I wanted to share it here first to see if a PR would be welcome
Bug Description
On Windows environments running Python 3.13+,
test_multipart_encode_files_raises_exception_with_text_mode_fileconsistently fails. The test expects a TypeError when a file opened in text mode (mode="w") is passed into multipart file encoding, but under Python 3.13 on Windows, no exception is thrown.Environment Information
To Reproduce
Run the multipart unit tests on a Windows environment with Python 3.13:
Alternatively, executing the core logic manually in an interactive prompt:
Expected Behavior
A TypeError should be explicitly raised to catch text-mode file streams uniformly across platforms, ensuring data integrity before multipart payload assembly.
Actual Behavior
The test suite fails with:
Proposed Solution / Context
The underlying behavior of empty text-mode tempfile.TemporaryFile objects appears to skip typical stream type check constraints under Python 3.13 on the Windows platform. I can submit a patch to strictly check the file stream typing or check if binary mode is explicitly missing within httpx/_multipart.py to fix this consistently if you'd like!
All reactions