Author: guido.van.rossum
Date: Tue May 15 23:32:59 2007
New Revision: 55357

Modified:
   python/branches/py3k-struni/Lib/test/test_builtin.py
   python/branches/py3k-struni/Python/bltinmodule.c
Log:
It's ok for __hex__ or __oct__ to return unicode.
Don't insist that float('1'*10000) raises an exception.


Modified: python/branches/py3k-struni/Lib/test/test_builtin.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_builtin.py        (original)
+++ python/branches/py3k-struni/Lib/test/test_builtin.py        Tue May 15 
23:32:59 2007
@@ -608,8 +608,7 @@
         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):

Modified: python/branches/py3k-struni/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k-struni/Python/bltinmodule.c    (original)
+++ python/branches/py3k-struni/Python/bltinmodule.c    Tue May 15 23:32:59 2007
@@ -1230,7 +1230,7 @@
                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 @@
                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);
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to