diff options
-rw-r--r-- | Lib/test/test_builtin.py | 3 | ||||
-rw-r--r-- | Python/bltinmodule.c | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index a11e40a..54df9e1 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -608,8 +608,7 @@ class BuiltinTest(unittest.TestCase): if have_unicode: self.assertEqual(float(str(" 3.14 ")), 3.14) self.assertEqual(float(str(b" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) - # Implementation limitation in PyFloat_FromString() - self.assertRaises(ValueError, float, str("1"*10000)) + self.assertEqual(float("1"*10000), 1e10000) # Inf on both sides @run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE') def test_float_with_comma(self): diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index aa0d0df..064b92a 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1230,7 +1230,7 @@ builtin_hex(PyObject *self, PyObject *v) return NULL; } res = (*nb->nb_hex)(v); - if (res && !PyString_Check(res)) { + if (res && !PyString_Check(res) && !PyUnicode_Check(res)) { PyErr_Format(PyExc_TypeError, "__hex__ returned non-string (type %.200s)", res->ob_type->tp_name); @@ -1430,7 +1430,7 @@ builtin_oct(PyObject *self, PyObject *v) return NULL; } res = (*nb->nb_oct)(v); - if (res && !PyString_Check(res)) { + if (res && !PyString_Check(res) && !PyUnicode_Check(res)) { PyErr_Format(PyExc_TypeError, "__oct__ returned non-string (type %.200s)", res->ob_type->tp_name); |