#!/usr/bin/env python3 '''Test cases for bytes join bug. This code behaves as expected: >>> ' '.join('cat') 'c a t' This code does not: >>> b'\\x00'.join(b'cat') b'c\\x00a\\x00t' Instead, you have to do something like this: >>> b'\\x00'.join(bytes((i,)) for i in b'cat') b'c\\x00a\\x00t' Same problem with bytes or bytearray in either position: >>> b'\\x00'.join(bytearray(b'cat')) b'c\\x00a\\x00t' >>> bytearray(b'\\x00'.join(b'cat')) bytearray(b'c\\x00a\\x00t') ''' import doctest doctest.testmod()