##// END OF EJS Templates
Handle tokenizing errors when checking if the ? at the end of the line is in a comment....
Thomas Kluyver -
Show More
@@ -173,7 +173,12 b' def has_comment(src):'
173 Boolean: True if source has a comment.
173 Boolean: True if source has a comment.
174 """
174 """
175 readline = StringIO(src).readline
175 readline = StringIO(src).readline
176 toktypes = set(t[0] for t in tokenize.generate_tokens(readline))
176 toktypes = set()
177 try:
178 for t in tokenize.generate_tokens(readline):
179 toktypes.add(t[0])
180 except tokenize.TokenError:
181 pass
177 return(tokenize.COMMENT in toktypes)
182 return(tokenize.COMMENT in toktypes)
178
183
179
184
@@ -472,6 +472,7 b' syntax = \\'
472 ('a = abc?', 'get_ipython().magic(u"pinfo abc", next_input=u"a = abc")'),
472 ('a = abc?', 'get_ipython().magic(u"pinfo abc", next_input=u"a = abc")'),
473 ('a = abc.qe??', 'get_ipython().magic(u"pinfo2 abc.qe", next_input=u"a = abc.qe")'),
473 ('a = abc.qe??', 'get_ipython().magic(u"pinfo2 abc.qe", next_input=u"a = abc.qe")'),
474 ('a = *.items?', 'get_ipython().magic(u"psearch *.items", next_input=u"a = *.items")'),
474 ('a = *.items?', 'get_ipython().magic(u"psearch *.items", next_input=u"a = *.items")'),
475 ('plot(a?', 'get_ipython().magic(u"pinfo a", next_input=u"plot(a")'),
475 ('a*2 #comment?', 'a*2 #comment?'),
476 ('a*2 #comment?', 'a*2 #comment?'),
476 ],
477 ],
477
478
General Comments 0
You need to be logged in to leave comments. Login now