Fix all BytesWarning caught during tests by jdufresne · Pull Request #5561 · encode/django-rest-framework (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The %s
placeholder implies a call to str()
before substitution. In Python3, this looks like:
print('%s' % b'foo') b'foo'
So, the end result of the formatted string is something like "test/*; foo=b'bar'"
. Notice the extra characters b''
. My understanding is this repr bytes value was not intended as part of the return value. If true, this wasn't previously correct. Enabling BytesWarning caught this bug. This was caught by fixing the test test_mediatype_string_representation()
.