# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1162773046 28800
# Node ID c5bbdfb6168859a83462b061784673d6e4f7e4cc
# Parent  9bd772e2980bd58f8025568f9451e75452b30b84
Fixed bug in preparser where it got confused by comments.

  This bug was reported by Justin Walker and Andrey Novoseltsev

diff -r 9bd772e2980b -r c5bbdfb61688 sage/misc/preparser.py
--- a/sage/misc/preparser.py	Sun Nov 05 10:34:40 2006 -0800
+++ b/sage/misc/preparser.py	Sun Nov 05 16:30:46 2006 -0800
@@ -311,6 +311,12 @@ def preparse(line, reset=True, do_time=F
                                           or line[i-1] == ')'))):
             in_number = True
             num_start = i
+            
+        # Decide if we hit a comment, so we're done.
+        if line[i] == '#' and not (in_single_quote or in_double_quote or in_triple_quote):
+            i = len(line)
+            break
+
         i += 1
 
     if in_number:
