HttpResponse._get_content shouldn't accept non-text types
|Reported by:||aaugustin||Owned by:||aaugustin|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, the httpwrappers tests verify the behavior of constructs such as HttpResponse([1,1,2,4,8]). This doesn't make any sense to me.
HttpResponse must convert its content to bytes. But when a Content-Encoding is already set, it mustn't perform any encoding, so it can't go through a unicode representation.
Now, in Python 3, bytes(3) == \x00\x00\x00. So I don't see any way to implement the construct above in Python 3 without special-casing integers.
Rather than explicitly hacking a meaningless behavior, I'd like to remove these tests and require that HttpResponse be instantiated with a (byte)string or an iterable of (byte)strings.
I'm marking this as a release blocker because it causes a test failure under Python 3 (httpwrappers.HttpResponseTests.test_iter_content).
Change History (7)
Changed 3 years ago by aaugustin
comment:4 Changed 3 years ago by aaugustin
- Has patch set
- Triage Stage changed from Accepted to Ready for checkin
comment:5 Changed 3 years ago by Aymeric Augustin <aymeric.augustin@…>
- Resolution set to fixed
- Status changed from new to closed