Amaury Forgeot d'Arc <[email protected]> added the comment:

Yes, CPython behavior is odd when default=3.
This is because of a misuse of the "is" operator in argparse.py, line 1783:
    if argument_values is not action.default:

Now, when you pass -b 3, will the value be identical to action.default? This 
depends how the object int("3") is 
constructed. Here CPython caches small integers, and int("3") is 3. But 
int("1000") is not 1000.
And CPython does not cache floats (even 0.0)

PyPy is a bit different, and int(x) is x, always:
http://pypy.readthedocs.org/en/latest/cpython_differences.html#object-identity-of-primitive-values-is-and-id

If it's important, argparse should be rewritten to not rely on the identity of 
ints or floats.

----------
nosy: +amaury
status: unread -> chatting

________________________________________
PyPy bug tracker <[email protected]>
<https://bugs.pypy.org/issue1595>
________________________________________
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to