Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
Bug report
Bug description:
When setting the default of an argument to sys.stdout and the type isargparse.FileType("wb")
then the class should be_io.BufferedWriter
not_io.TextIOWrapper
when no arguments are provided. When the argument is set to-
then the class is correctly set to_io.BufferedWriter
as expected.
importargparseimportsysparser=argparse.ArgumentParser()parser.add_argument("outfile",nargs="?",type=argparse.FileType("wb"),default=sys.stdout)args=parser.parse_args("-")print(type(args.outfile))# <class '_io.BufferedWriter'># Correctargs=parser.parse_args()print(type(args.outfile))# <class '_io.TextIOWrapper'># Incorrect
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Projects
Status
No status