[New-bugs-announce] [issue9347] Calling argparse add_argument with a sequence as 'type' causes spurious error message
Steven Bethard
report at bugs.python.org
Fri Jul 23 15:27:50 CEST 2010
New submission from Steven Bethard <steven.bethard at gmail.com>:
What steps will reproduce the problem?
parser = argparse.ArgumentParser()
parser.add_argument('--foo', type=(int, float))
What is the expected output?
ValueError: (<type 'int'>, <type 'float'>) is not callable
What do you see instead?
TypeError: not all arguments converted during string formatting
Please provide any additional information below.
This is caused by calling using the % string formatting operator without
proper wrapping of the argument. The fix is basically:
- raise ValueError('%r is not callable' % type_func)
+ raise ValueError('%r is not callable' % (type_func,))
----------
components: Library (Lib)
messages: 111316
nosy: bethard
priority: low
severity: normal
stage: needs patch
status: open
title: Calling argparse add_argument with a sequence as 'type' causes spurious error message
type: behavior
versions: Python 2.7, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9347>
_______________________________________
More information about the New-bugs-announce
mailing list