def path_string(s):
 if isinstance(s, binary_type):
  return s
 elif isinstance(s, text_type):
  return s.encode(sys.getfilesystemencoding())
 else:
  raise TypeError('Path must be represented as bytes or unicode string')

def path_string ( s ) : if isinstance ( s , binary_type ) : return s elif isinstance ( s , text_type ) : return s . encode ( sys . getfilesystemencoding ( ) ) else : raise TypeError ( 'Path must be represented as bytes or unicode string' )
convert a python string to a :py:class:bytes string identifying the same path and which can be passed into an openssl api accepting a filename .