def toBytes(x):
if isinstance(x, bytes):<EOL><INDENT>return x<EOL><DEDENT>elif isinstance(x, bytearray):<EOL><INDENT>return bytes(x)<EOL><DEDENT>elif isinstance(x, unicode):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return x  <EOL><DEDENT>return encode(x, DEF_ENCODING)<EOL>
x-->unicode string | bytearray | bytes
Returns-->bytes
If x is unicode, MUST have encoding=latin1