]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Change the order in which Floatnumber and Intnumber are tried
authorGuido van Rossum <guido@python.org>
Mon, 16 Mar 1992 18:30:24 +0000 (18:30 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 16 Mar 1992 18:30:24 +0000 (18:30 +0000)
so it will correctly recognize floats.
Fix the test program so it works again.

Lib/tokenize.py

index 6b3d991a960c570ef278ebbb89a72cbaaca44275..bd047f860d4050d81272d4f4c27b49dfd4ce3f63 100644 (file)
@@ -22,7 +22,7 @@ Exponent = '[eE][-+]?[0-9]+'
 Pointfloat = '\([0-9]+\.[0-9]*\|\.[0-9]+\)\(' + Exponent + '\)?'
 Expfloat = '[0-9]+' + Exponent
 Floatnumber = Pointfloat + '\|' + Expfloat
-Number = Intnumber + '\|' + Floatnumber
+Number = Floatnumber + '\|' + Intnumber
 
 String = '\'\(\\\\.\|[^\\\n\']\)*\''
 
@@ -39,7 +39,8 @@ try:
        save_syntax = regex.set_syntax(0) # Use default syntax
        tokenprog = regex.compile(Token)
 finally:
-       dummy = regex.set_syntax(save_syntax) # Restore original syntax
+       if save_syntax != 0:
+               dummy = regex.set_syntax(save_syntax) # Restore original syntax
 
 
 def test(file):