ttm / pyo

Automatically exported from code.google.com/p/pyo
GNU General Public License v3.0
0 stars 0 forks source link

Failed type-checks and other errors quit the python interpreter #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To reproduce, enter the following at a python prompt:

>>> from pyo import *
>>> s = Server().boot()
>>> a = Sin(1)

The result is that the python interpreter quits with the message, "TypeError: 
"input" argument must be a PyoObject." Instead, it should throw an exception, 
but the interpreter should continue running. This is caused by calling 
Py_Exit(1); as the standard way of dealing with error conditions, instead of 
using the exception routines, such as PyErr_SetString().

This is catastrophic for using pyo in interactive contexts, as any such minor 
mistake will quit the interpreter and force you to start again.

I am sure there are other instances of this mistake - pressing the Quit button 
in the GUI also quits the interpreter if there is one! So if you want to launch 
the GUI to view some waveforms, you must set up another thread in the 
interpreter because otherwise once you start it, you can never get the 
interpreter back!

Original issue reported on code.google.com by thefishf...@gmail.com on 3 Sep 2013 at 9:49

GoogleCodeExporter commented 9 years ago
In the same vein, I noticed that if you create a second server object a message 
is printed to stderr with some warning. This is not proper behaviour for a 
python module! If an illegal action is performed, an exception ought to be 
thrown to inform the programmer, *not* printing to stderr (which may be 
redirected to somewhere other than where exceptions are seen!)

Original comment by thefishf...@gmail.com on 6 Sep 2013 at 10:58

GoogleCodeExporter commented 9 years ago
This is fixed in sources (rev 1205). 

An exception is raised for wrong argument that must be a pyo's specific object 
(PyoObject, PyoTableObject, PyoMatrixObject, PyoPVObject). That no more quit 
the interpreter.

You can show the server gui with s.gui(exit=False) to disable sys.exit() when 
the 'Quit' button is pressed. If the server is started, this can be done only 
once...

Original comment by belan...@gmail.com on 16 Aug 2014 at 3:10