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 2011年10月26日 21:25 by Joshua.Chia, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| test.py | Joshua.Chia, 2013年03月31日 21:32 | |||
| Messages (6) | |||
|---|---|---|---|
| msg146458 - (view) | Author: Joshua Chia (Joshua.Chia) | Date: 2011年10月26日 21:25 | |
What steps will reproduce the problem?
1. Make a script containing this code:
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input-base-directory',
type=argparse.FileType('r'),
default='/home')
parser.parse_args()
2. Run the script with '-h'.
3. See it complain that '/home' is a directory
Detailed explanation:
With '-h', we just need to print the help message. We shouldn't fail on a default value that's wrong or else the help message will not get printed and the user will have no idea what the problem is. This is a valid use case as I want to provide a default location, but I can't guarantee that the location works on the user's machine. I end up doing my own checking.
|
|||
| msg146496 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年10月27日 15:46 | |
I’d argue this is a behavior bug that could be fixed in 2.7 and 3.2 too, but Steven will decide. |
|||
| msg146826 - (view) | Author: Petri Lehtinen (petri.lehtinen) * (Python committer) | Date: 2011年11月02日 06:34 | |
Sounds like a but to me, too. |
|||
| msg149530 - (view) | Author: Steven Bethard (bethard) * (Python committer) | Date: 2011年12月15日 11:01 | |
I think http://bugs.python.org/issue12776, which delays type conversions on defaults should solve this problem, right? If you agree, could you add your code here as a test case to that issue and mark this as duplicate? (And yes, I agree this is a bug.) |
|||
| msg185678 - (view) | Author: Joshua Chia (Joshua.Chia) | Date: 2013年03月31日 21:32 | |
Added test case |
|||
| msg185680 - (view) | Author: Joshua Chia (Joshua.Chia) | Date: 2013年03月31日 21:34 | |
Seems to be duplicate of http://bugs.python.org/issue12776 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:23 | admin | set | github: 57480 |
| 2013年03月31日 21:51:07 | eric.araujo | set | superseder: argparse: type conversion function should be called only once stage: test needed -> resolved |
| 2013年03月31日 21:34:04 | Joshua.Chia | set | messages: + msg185680 |
| 2013年03月31日 21:32:55 | Joshua.Chia | set | status: open -> closed files: + test.py resolution: duplicate messages: + msg185678 |
| 2012年03月18日 21:39:46 | tshepang | set | nosy:
+ tshepang |
| 2011年12月15日 11:01:57 | bethard | set | messages: + msg149530 |
| 2011年11月02日 06:34:33 | petri.lehtinen | set | stage: test needed messages: + msg146826 versions: + Python 2.7, Python 3.2 |
| 2011年10月27日 15:46:42 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg146496 versions: + Python 3.3, - Python 2.7 |
| 2011年10月27日 12:28:28 | petri.lehtinen | set | nosy:
+ petri.lehtinen |
| 2011年10月27日 01:30:53 | eric.smith | set | nosy:
+ bethard, eric.smith |
| 2011年10月26日 21:25:51 | Joshua.Chia | create | |