noamraph / dreampie

DreamPie - The Python shell you've always dreamed about!
www.dreampie.org
GNU General Public License v3.0
235 stars 53 forks source link

Crash on pasting text. #54

Open welbornprod opened 10 years ago

welbornprod commented 10 years ago

The report was this:

Variables: File "/home/cj/.local/lib/python2.7/site-packages/dreampielib/gui/init.py", line 960, on_execute_command(self=DreamPie(path..."window_main"), _widget=<gtk.Men...27979a0)>) {'self.execute_source': <bound method DreamPie.execute_source of DreamPie(path="/home/cj/.local/lib/python2.7/site-packages/dreampielib/data/dreampie.glade", root="window_main")>} File "/home/cj/.local/lib/python2.7/site-packages/dreampielib/gui/init.py", line 497, execute_source(self=DreamPie(path..."window_main")) {'is_ok': [], 'syntax_error_info': [], 'source': u'doc = """

<.....~60 lines of html string omitted here, because GitHub is trying to parse it. ...>

"""', 'self.call_subp': <bound method DreamPie.call_subp of DreamPie(path="/home/cj/.local/lib/python2.7/site-packages/dreampielib/data/dreampie.glade", root="window_main")>}

Traceback (most recent call last): File "/home/cj/.local/lib/python2.7/site-packages/dreampielib/gui/init.py", line 960, in on_execute_command self.execute_source() File "/home/cj/.local/lib/python2.7/site-packages/dreampielib/gui/init.py", line 497, in execute_source is_ok, syntax_error_info = self.call_subp(u'execute', source) TypeError: 'NoneType' object is not iterable

welbornprod commented 10 years ago

I can reproduce it by restarting DreamPie and pasting it again. Since github is trying to parse the html I pasted the failing text on my site:

http://welbornprod.com/paste/?id=gezx

It's not code that goes into any of my programs, just a small test I was running with lxml.html.

welbornprod commented 10 years ago

I know what caused it. I had embedded python code inside of that string, with docstrings in it.

So.. this made it crash: txt = """ <-html stuff-> """ python stuff """ <-more html stuff-> """

The fix was to do this:

txt = ''' <-html stuff-> """ python stuff """ <- more html stuff -> '''

(just changed the triple-quote style)

Oddly, I discovered it by reverting back to IDLE, where I got SyntaxError: invalid syntax. When I saw that I immediately realized what had happened.