[pypy-svn] r12739 - in pypy/dist/pypy/objspace/std: . test

ac at codespeak.net ac at codespeak.net
Mon May 23 13:50:38 CEST 2005


Author: ac
Date: Mon May 23 13:50:38 2005
New Revision: 12739

Modified:
   pypy/dist/pypy/objspace/std/longtype.py
   pypy/dist/pypy/objspace/std/test/test_unicodestring.py
Log:
Fix creation of long from unicode.

Modified: pypy/dist/pypy/objspace/std/longtype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/longtype.py	(original)
+++ pypy/dist/pypy/objspace/std/longtype.py	Mon May 23 13:50:38 2005
@@ -20,9 +20,8 @@
                                      space.wrap(e.msg))
         elif space.is_true(space.isinstance(w_value, space.w_unicode)):
             try:
-                # XXX can produce unwrapped long
                 from unicodeobject import unicode_to_decimal_w
-                value = string_to_long(unicode_to_decimal_w(space, w_value))
+                w_value = string_to_w_long(space, unicode_to_decimal_w(space, w_value))
             except ParseStringError, e:
                 raise OperationError(space.w_ValueError,
                                      space.wrap(e.msg))

Modified: pypy/dist/pypy/objspace/std/test/test_unicodestring.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_unicodestring.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_unicodestring.py	Mon May 23 13:50:38 2005
@@ -64,3 +64,12 @@
         assert (u'this!is!the!split!function'.split('!') ==
                 [u'this', u'is', u'the', u'split', u'function'])
     
+    def test_long_from_unicode(self):
+        assert long(u'12345678901234567890') == 12345678901234567890
+        assert int(u'12345678901234567890') == 12345678901234567890
+
+    def test_int_from_unicode(self):
+        assert int(u'12345') == 12345
+
+    def test_float_from_unicode(self):
+        assert float(u'123.456e89') == 123.456e89



More information about the Pypy-commit mailing list