Fix BodyPartReader.read() returning bytearray instead of bytes#12466
Fix BodyPartReader.read() returning bytearray instead of bytes#12466mitre88 wants to merge 1 commit intoaio-libs:masterfrom
Conversation
BodyPartReader.read() was returning the internal bytearray buffer directly instead of bytes, violating the annotated return type. This caused TypeError when downstream code (like json.dump) tried to serialize the value since bytearray is not JSON serializable. The fix wraps the return values with bytes() to match the annotated return type. Fixes aio-libs#12404
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12466 +/- ##
=======================================
Coverage 98.92% 98.92%
=======================================
Files 134 134
Lines 46750 46750
Branches 2429 2429
=======================================
Hits 46248 46248
Misses 373 373
Partials 129 129
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Merging this PR will not alter performance
Comparing Footnotes
|
BodyPartReader.read() was returning the internal bytearray buffer directly instead of bytes, violating the annotated return type of
bytes.This caused
TypeError: Object of type bytearray is not JSON serializablewhen downstream code (likejson.dump) tried to serialize the value.The fix wraps the return values with
bytes()to match the annotated return type.Fixes #12404