When running python3 -bb, why does set([b'foo', u'foo']) fail but set([b'foo', u'bar']) succeed?

Viewed 82

I was trying to make some code str(bytes) safe on Python 3 by adding the -bb argument, which turns both str(bytes) and bytes/str comparisons into an error.

issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str. (-bb: issue errors)

The program failed because a library was trying to build a set containing both str and bytes, but it doesn't reproduce interactively: set([b'foo', u'bar']) works. Why does only set([b'foo', u'foo']) fail?

0 Answers
Related