]> granicus.if.org Git - python/commit
bpo-37150: Throw ValueError if FileType class object was passed in add_argument ...
authorzygocephalus <grrrr@protonmail.com>
Fri, 7 Jun 2019 20:08:36 +0000 (23:08 +0300)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 7 Jun 2019 20:08:36 +0000 (13:08 -0700)
commit03d5831a2d62c68654ec223168e574cd546efbf6
treee1d26a353a8269cfaf0fd2f1518bf7907c16f116
parent1f9531764cc0f8dbca1d8f429d162dc28282f4b4
bpo-37150: Throw ValueError if FileType class object was passed in add_argument (GH-13805)

There is a possibility that someone (like me) accidentally will omit parentheses with `FileType` arguments after `FileType`, and parser will contain wrong file until someone will try to use it.

Example:
```python
parser = argparse.ArgumentParser()
parser.add_argument('-x', type=argparse.FileType)
```

https://bugs.python.org/issue37150
Lib/argparse.py
Lib/test/test_argparse.py
Misc/NEWS.d/next/Library/2019-06-04-14-44-41.bpo-37150.TTzHxj.rst [new file with mode: 0644]