'Dump to a py2-unicode or py3-string stream.'

def _dump_stream(self, obj, stream, dumper=None):

    if PY3:
        return yaml.dump(obj, stream, Dumper=dumper)
    else:
        return yaml.dump(obj, stream, Dumper=dumper, encoding=None)
