This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年03月23日 07:03 by shima__shima, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| argparse.py.patch | shima__shima, 2012年03月23日 07:03 | |||
| Messages (6) | |||
|---|---|---|---|
| msg156636 - (view) | Author: Toshihiro Kamishima (shima__shima) | Date: 2012年03月23日 07:03 | |
According to the documentation of "argparse.Action", a keyword 'bool' is not allowed for type argument, but it doesn't raise no errors. One possible way to fix this issue is to check in the "argparse._ActionsContainer.add_argument" method. |
|||
| msg156728 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年03月25日 00:56 | |
This change maked the error message wrong if bool is rejected. |
|||
| msg156729 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年03月25日 00:59 | |
The corresponding current code in 3.2 and 3.3 is the same. |
|||
| msg156745 - (view) | Author: Toshihiro Kamishima (shima__shima) | Date: 2012年03月25日 09:05 | |
Thank you for your response. My patch makes raise error by minimal change, but it may be better to raise NameError as in a case specifying "type=string" in 2.7.2. Similar to the case "type=bool", specifications, such as "type=unicode" or "type=long", don't raise errors. Because the set of problematic keywords are different between 2.7.x and 3.3.x, I have no idea to completely fix this problem. |
|||
| msg166062 - (view) | Author: Steven Bethard (bethard) * (Python committer) | Date: 2012年07月21日 20:19 | |
I can't find anywhere in the documentation where type=bool, type=unicode or type=long are disallowed. They shouldn't be disallowed. If you want to pass type=bool, argparse should not stop you. And it currently doesn't:
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo', type=bool)
>>> parser.parse_args([''])
Namespace(foo=False)
>>> parser.parse_args(['x'])
Namespace(foo=True)
|
|||
| msg166093 - (view) | Author: Toshihiro Kamishima (shima__shima) | Date: 2012年07月22日 00:10 | |
> - type -- The type which the command-line arguments should be converted > to, should be one of 'string', 'int', 'float', 'complex' or a > callable object that accepts a single string argument. If None, > 'string' is assumed. I misunderstood this sentence in the docstring of arcparse.Action because `bool` or `unicode` is not appeared in this list, which are callables. So, I close this issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:28 | admin | set | github: 58600 |
| 2017年01月10日 00:45:51 | paul.j3 | set | nosy:
+ paul.j3 |
| 2012年07月22日 00:10:21 | shima__shima | set | status: open -> closed resolution: rejected messages: + msg166093 |
| 2012年07月21日 20:19:39 | bethard | set | messages: + msg166062 |
| 2012年03月25日 09:05:40 | shima__shima | set | messages: + msg156745 |
| 2012年03月25日 00:59:03 | terry.reedy | set | messages:
+ msg156729 versions: + Python 3.2, Python 3.3 |
| 2012年03月25日 00:56:05 | terry.reedy | set | nosy:
+ terry.reedy, bethard messages: + msg156728 type: behavior stage: test needed |
| 2012年03月23日 07:03:28 | shima__shima | create | |