+    # For example, PyPy 1.9.0 raised TypeError for these cases because it
+    # expects x to be a string if base is given.
+    @support.cpython_only
+    def test_base_arg_with_no_x_arg(self):
+        self.assertEquals(int(base=6), 0)
+        # Even invalid bases don't raise an exception.
+        self.assertEquals(int(base=1), 0)
+        self.assertEquals(int(base=1000), 0)
+        self.assertEquals(int(base='foo'), 0)

I think the above behavior is buggy and should be changed rather than frozen into CPython with a test. According to the docs, PyPy does it right.

The current online doc gives the signature as
int(x=0)
int(x, base=10) <<where x is s string>>

The 3.3.0 docstring says
"When converting a string, use the optional base. It is an error to supply a base when converting a non-string."

Certainly, accepting any object as a base, violating "The allowed values are 0 and 2-36." just because giving a base is itself invalid is crazy.

--
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to