[issue21416] argparse should accept bytes arguments as originally passed

paul j3 report at bugs.python.org
Wed May 28 06:33:38 CEST 2014


paul j3 added the comment:

'invalid bytes value' is the error message generated by 'argparse'.  The underlying error (for a string like 'xxx') is:

    print(bytes(sys.argv[1]))
    TypeError: string argument without an encoding

You could use 'bytes' if you somehow supply the encoding, as in:

    def mybytes(astr):
       return bytes(astr, 'utf-8')

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21416>
_______________________________________


More information about the Python-bugs-list mailing list