Skip to content
This repository

ipython explodes on syntax error #1054

Closed
jkbbwr opened this Issue November 27, 2011 · 2 comments

2 participants

Jacob Thomas Kluyver
Jacob

The following code
def explodenow():
yield 1
return 1

Causes the following error to fire off

SyntaxError Python 2.7.2: C:\Python27\python.exe
Sun Nov 27 14:24:41 2011
A problem occured executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
C:\Python27\Scripts\ipython-script.py in ()
1 #!C:\Python27\python.exe
2 # EASY-INSTALL-ENTRY-SCRIPT: 'ipython==0.11','console_scripts','ipython'

  3 __requires__ = 'ipython==0.11'
  4 import sys
  5 from pkg_resources import load_entry_point
  6
  7 if __name__ == '__main__':
  8     sys.exit(

----> 9 load_entry_point('ipython==0.11', 'console_scripts', 'ipython')(
)
global load_entry_point = E8>
10 )

C:\Python27\lib\site-packages\IPython\frontend\terminal\ipapp.pyc in launch_new_
instance()
355 ipython_dir = get_ipython_dir()
356 profile_dir = os.path.join(ipython_dir, 'profile_default')
357 cl = PyFileConfigLoader(default_config_file_name, profile_dir)
358 try:
359 config = cl.load_config()
360 except IOError:
361 # no config found
362 config = Config()
363 return config
364
365
366 def launch_new_instance():
367 """Create and run a full blown IPython instance"""
368 app = TerminalIPythonApp.instance()
369 app.initialize()
--> 370 app.start()
371
372
373 if name == 'main':
374 launch_new_instance()

C:\Python27\lib\site-packages\IPython\frontend\terminal\ipapp.pyc in start(self=
)
329 if gui or self.pylab:
330 try:
331 self.log.info("Enabling GUI event loop integration, "
332 "toolkit=%s, pylab=%s" % (gui, self.pylab)
)
333 activate(gui)
334 except:
335 self.log.warn("Error in enabling GUI event loop integrat
ion:")
336 self.shell.showtraceback()
337
338 def start(self):
339 if self.subapp is not None:
340 return self.subapp.start()
341 # perform any prexec steps:
342 if self.interact:
343 self.log.debug("Starting IPython's mainloop...")
--> 344 self.shell.mainloop()
345 else:
346 self.log.debug("IPython not interactive...")
347
348
349 def load_default_config(ipython_dir=None):
350 """Load the default config file from the default ipython_dir.
351
352 This is useful for embedded shells.
353 """
354 if ipython_dir is None:
355 ipython_dir = get_ipython_dir()
356 profile_dir = os.path.join(ipython_dir, 'profile_default')
357 cl = PyFileConfigLoader(default_config_file_name, profile_dir)
358 try:
359 config = cl.load_config()

C:\Python27\lib\site-packages\IPython\frontend\terminal\interactiveshell.pyc in
mainloop(self= ll object>, display_banner=None)

207 #-------------------------------------------------------------------

208     # Mainloop and code execution logic
209     #-------------------------------------------------------------------

210
211     def mainloop(self, display_banner=None):
212         """Start the mainloop.
213
214         If an optional banner argument is given, it will override the
215         internally created default banner.
216         """
217
218         with nested(self.builtin_trap, self.display_trap):
219
220             while 1:
221                 try:

--> 222 self.interact(display_banner=display_banner)
global See = undefined
global also = undefined
223 #self.interact_with_readline()
224 # XXX for testing of a readline-decoupled repl loop,
call
225 # interact_with_readline above
226 break
227 except KeyboardInterrupt:
228 # this should not be necessary, but KeyboardInterrup
t
229 # handling seems rather unpredictable...
230 self.write("\nKeyboardInterrupt in interact()\n")
231
232 def interact(self, display_banner=None):
233 """Closely emulate the interactive Python console."""
234
235 # batch run -> do not interact
236 if self.exit_now:
237 return

C:\Python27\lib\site-packages\IPython\frontend\terminal\interactiveshell.pyc in
interact(self= ll object>, display_banner=False)
297 'Because of how pdb handles the stack, it is imposs
ible\n'
298 'for IPython to properly format this particular exc
eption.\n'
299 'IPython will resume normal operation.')
300 except:
301 # exceptions here are VERY RARE, but they can be trigger
ed
302 # asynchronously by signal handlers, for example.
303 self.showtraceback()
304 else:
305 self.input_splitter.push(line)
306 more = self.input_splitter.push_accepts_more()
307 if (self.SyntaxTB.last_syntax_error and
308 self.autoedit_syntax):
309 self.edit_syntax_error()
310 if not more:
311 source_raw = self.input_splitter.source_raw_reset()[
1]
--> 312 self.run_cell(source_raw)
313
314 # We are off again...
315 builtin.dict['__IPYTHON__active'] -= 1
316
317 # Turn off the exit flag, so the mainloop can be restarted if de
sired
318 self.exit_now = False
319
320 def raw_input(self, prompt=''):
321 """Write a prompt and read a line.
322
323 The returned line does not include the trailing newline.
324 When the user enters the EOF key sequence, EOFError is raised.
325
326 Optional inputs:
327

C:\Python27\lib\site-packages\IPython\core\interactiveshell.pyc in run_cell(self
=, r
aw_cell=u'def test():\n yield 1\n return 1\n', store_history=True)
2282
2283 with self.display_trap:
2284 try:
2285 code_ast = ast.parse(cell, filename=cell_name)
2286 except IndentationError:
2287 self.showindentationerror()
2288 self.execution_count += 1
2289 return None
2290 except (OverflowError, SyntaxError, ValueError, Type
Error,
2291 MemoryError):
2292 self.showsyntaxerror()
2293 self.execution_count += 1
2294 return None
2295
2296 self.run_ast_nodes(code_ast.body, cell_name,
-> 2297 interactivity="l
ast_expr")
2298
2299 # Execute any registered post-execution functions.
2300 for func, status in self._post_execute.iteritems():
2301 if not status:
2302 continue
2303 try:
2304 func()
2305 except:
2306 self.showtraceback()
2307 # Deactivate failing function
2308 self._post_execute[func] = False
2309
2310 if store_history:
2311 # Write output to the database. Does nothing unless
2312 # history output logging is enabled.

C:\Python27\lib\site-packages\IPython\core\interactiveshell.pyc in run_ast_nodes
(self= t>, nodelist=[<_ast.FunctionDef object>], cell_name=' 53>', interactivity='none')
2342 interactivity = "none"
2343
2344 if interactivity == 'none':
2345 to_run_exec, to_run_interactive = nodelist, []
2346 elif interactivity == 'last':
2347 to_run_exec, to_run_interactive = nodelist[:-1], nodelist[-1
:]
2348 elif interactivity == 'all':
2349 to_run_exec, to_run_interactive = [], nodelist
2350 else:
2351 raise ValueError("Interactivity was %r" % interactivity)
2352
2353 exec_count = self.execution_count
2354
2355 for i, node in enumerate(to_run_exec):
2356 mod = ast.Module([node])
-> 2357 code = self.compile(mod, cell_name, "exec")
2358 if self.run_code(code):
2359 return True
2360
2361 for i, node in enumerate(to_run_interactive):
2362 mod = ast.Interactive([node])
2363 code = self.compile(mod, cell_name, "single")
2364 if self.run_code(code):
2365 return True
2366
2367 return False
2368
2369 def run_code(self, code_obj):
2370 """Execute a code object.
2371
2372 When an exception occurs, self.showtraceback() is called to disp
lay a

C:\Python27\lib\codeop.pyc in call(self= iler instance>, source=<_ast.Module object>, filename=' 2a53>', symbol='exec')
118 - Raise SyntaxError, ValueError or OverflowError if the command is a

119       syntax error (OverflowError and ValueError can be produced by
120       malformed literals).
121     """
122     return _maybe_compile(_compile, source, filename, symbol)
123
124 class Compile:
125     """Instances of this class behave much like the built-in compile
126     function, but if one is used to compile text containing a future
127     statement, it "remembers" and compiles all subsequent program texts
128     with the statement in force."""
129     def __init__(self):
130         self.flags = PyCF_DONT_IMPLY_DEDENT
131
132     def __call__(self, source, filename, symbol):

--> 133 codeob = compile(source, filename, symbol, self.flags, 1)
134 for feature in features:
135 if codeob.co_flags & feature.compiler_flag:
136 self.flags |= feature.compiler_flag
137 return codeob
138
139 class CommandCompiler:
140 """Instances of this class have __call_
methods identical in
141 signature to compile_command; the difference is that if the
142 instance compiles program text containing a future statement,
143 the instance 'remembers' and compiles all subsequent program texts
144 with the statement in force."""
145
146 def init(self,):
147 self.compiler = Compile()
148

SyntaxError: 'return' with argument inside generator ( a53>, line 3)


Oops, ipython crashed. We do our best to make it stable, but...

A crash report was automatically generated with the following information:

  • A verbatim copy of the crash traceback.
  • A copy of your input history during this session.
  • Data on your current ipython configuration.

It was left in the file named:
'C:\Users\Jakob.ipython\Crash_report_ipython.txt'
If you can email this file to the developers, the information in it will help
them in understanding and correcting the problem.

You can mail it to: Fernando Perez at fperez.net@gmail.com
with the subject 'ipython Crash Report'.

If you want to do it now, the following command will work (under Unix):
mail -s 'ipython Crash Report' fperez.net@gmail.com < C:\Users\Jakob.ipython\Cr
ash_report_ipython.txt

To ensure accurate tracking of this issue, please file a report about it at:
http://github.com/ipython/ipython/issues

Hit to quit this message (your terminal may close):

Thomas Kluyver
Collaborator

Thanks - we've already fixed it in the development version, which we hope to release in a few weeks.

Thomas Kluyver takluyver closed this November 27, 2011
Jacob

Thanks very much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.