Fix bug with preamble on Python 2

A check for a string was too strict, excluding a unicode string that
should have been accepted.