[issue16045] add more unit tests for built-in int()

Chris Jerdonek report at bugs.python.org
Tue Sep 25 19:01:51 CEST 2012


Chris Jerdonek added the comment:

Good thought.  Here is one data point:

$ pypy
Python 2.7.2 (341e1e3821fff77db3bb5cdb7a4851626298c44e, Jun 09 2012, 14:24:11)
[PyPy 1.9.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>> int()
0
>>>> int(x='10', base=8)
8
>>>> int(x=5, base=10) 
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: int() can't convert non-string with explicit base
>>>> int(base=6)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: int() can't convert non-string with explicit base
>>>> int(base='foo')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: expected integer, got str object

So it looks like "no x with given base" is where behavior differs.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16045>
_______________________________________


More information about the Python-bugs-list mailing list