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.

Author paul.j3
Recipients louielu, paul.j3
Date 2017-04-26.05:48:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
And only for integers smaller than 257!

The problem is with this test in `take_action` function

            # error if this argument is not allowed with other previously
            # seen arguments, assuming that actions that use the default
            # value don't really count as "present"
            if argument_values is not action.default:
                for conflict_action in action_conflicts.get(action, []):
                    if conflict_action in seen_non_default_actions:
                        msg = _('not allowed with argument %s')
                        action_name = _get_action_name(conflict_action)
                        raise ArgumentError(action, msg % action_name)

Specifically with the

    argument_values is not action.default

test.  In CPython integers below 257 are unique, so that

    In [33]: int('10') is 10
    Out[33]: True
    In [34]: int('257') is 257
    Out[34]: False

(and strings from 'sys.argv' do not match in the 'is' sense with strings set via 'default'.  So the problem is unique to small integers.)

The test is really meant to catch the default that is added in '_get_values()' for positionals with optional nargs ('?').

This issue was raised by some PyPy developers several years ago. 
 PyPy does not treat the small integers as unique.  I'll have to dig around to see what the resolution was, if any.

For now the solution is to use a string '10' as the default.
Date User Action Args
2017-04-26 05:48:52paul.j3setrecipients: + paul.j3, louielu
2017-04-26 05:48:52paul.j3setmessageid: <>
2017-04-26 05:48:52paul.j3linkissue30163 messages
2017-04-26 05:48:52paul.j3create