summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-03-16 18:30:24 (GMT)
committerGuido van Rossum <guido@python.org>1992-03-16 18:30:24 (GMT)
commit10d10ffb1b3c5d508b1f345ee40b19024e2514cc (patch)
treecddfafc11e91e5d379d897c9099cf933cbcb226d /Lib
parent29be3b97a6fd0ade24a980808087b9c1e507457b (diff)
downloadcpython-10d10ffb1b3c5d508b1f345ee40b19024e2514cc.zip
cpython-10d10ffb1b3c5d508b1f345ee40b19024e2514cc.tar.gz
cpython-10d10ffb1b3c5d508b1f345ee40b19024e2514cc.tar.bz2
Change the order in which Floatnumber and Intnumber are tried
so it will correctly recognize floats. Fix the test program so it works again.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/tokenize.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index 6b3d991..bd047f8 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -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):