Author: Stephan <[email protected]>
Branch: 
Changeset: r272:3ad9aee10951
Date: 2012-08-04 11:51 +0200
http://bitbucket.org/pypy/lang-js/changeset/3ad9aee10951/

Log:    fix parseInt

diff --git a/js/builtins_global.py b/js/builtins_global.py
--- a/js/builtins_global.py
+++ b/js/builtins_global.py
@@ -139,15 +139,23 @@
 
     numerals = NUMERALS[:r]
 
-    z = s
-    if not _string_match_chars(s, numerals):
-        z = u''
+    z = []
+    for char in s:
+        uni_ord = unicodedb.tolower(ord(char))
+        if uni_ord > 128:
+            break
+        c = chr(uni_ord)
+        if c not in numerals:
+            break
+        z.append(c)
 
-    if z == u'':
+    if not z:
         return NAN
 
+    num_str = ''.join(z)
+
     try:
-        number = int(str(z), r)
+        number = int(num_str, r)
         try:
             from pypy.rlib.rarithmetic import ovfcheck_float_to_int
             ovfcheck_float_to_int(number)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to