you can just do:

``source = source.encode(sys.getfilesystemencoding() or 'utf-8')``