[issue21416] argparse should accept bytes arguments as originally passed

2015-04-10 Thread Zachary Ware
Changes by Zachary Ware : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bu

[issue21416] argparse should accept bytes arguments as originally passed

2014-06-03 Thread Zachary Ware
Zachary Ware added the comment: The type parameter of ArgumentParser is a callable that will be called with the value of some member of sys.argv, it does *not* specify what the returned type will be. You can just use os.fsencode as the type argument: >>> import os >>> import argparse >>> p =

[issue21416] argparse should accept bytes arguments as originally passed

2014-05-27 Thread paul j3
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:

[issue21416] argparse should accept bytes arguments as originally passed

2014-05-27 Thread paul j3
paul j3 added the comment: Two points to keep in mind: 'argparse' works with 'sys.argv[1:]'. If that does not contain what you want, then you can pass your own 'argv' to 'parse_args'. 'type=bytes' means, call the builtin 'bytes' function with one of the argv strings. If 'bytes' does not hand

[issue21416] argparse should accept bytes arguments as originally passed

2014-05-02 Thread Derek Wilson
New submission from Derek Wilson: If I create an argument parser like: parser = argparse.ArgumentParser() parser.add_argument('somebytes', type=bytes, help='i want some bytes') parser.parse_args() the parse_args() call will raise an exception printing usage info indicating that an "invalid byt