gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
278 stars 62 forks source link

No exception on GDL errors in Python #41

Open slayoo opened 6 years ago

slayoo commented 6 years ago

(moved from https://sourceforge.net/p/gnudatalanguage/bugs/680/) As reported on SF by @olebole:

When a GDL routine has an error (for example, a undefined procedure), no exception is thrown, but instead one gets a GDL console:

$ cat pr.py 
import GDL
GDL.pro("rubbish")
$ cat rubbish.pro 
pro rubbish
  bla
end
$ python pr.py 
% Compiled module: RUBBISH.
% RUBBISH: Procedure not found: BLA
% Execution halted at: RUBBISH              2 [...]/rubbish.pro
%                      $MAIN$          
GDL> 

This makes it impossible to handle the problem within Python. Instead, an error should be given back. Ideally, also a Python stacktrace could be created containing the GDL trace as well.

olebole commented 5 years ago

Another example here is taken from #468. Suppose following GDL code:

PRO invalid_code
   this_is_invalid
end

In Python, an error message is printed, but no error is thrown:

>>> import GDL
>>> GDL.pro('invalid_code')
% Compiled module: INVALID_CODE.
% INVALID_CODE: Parser syntax error: unexpected token: