[GRASS-dev] Re: [GRASS GIS] #1646: GRASS ctypes exception handling

GRASS GIS trac at osgeo.org
Tue Apr 24 08:18:15 EDT 2012


#1646: GRASS ctypes exception handling
-----------------------------------------------------+----------------------
 Reporter:  huhabla                                  |       Owner:  grass-dev@…              
     Type:  enhancement                              |      Status:  new                      
 Priority:  normal                                   |   Milestone:  7.0.0                    
Component:  Python ctypes                            |     Version:  svn-trunk                
 Keywords:  setjmp, longjmp, Exception, gently exit  |    Platform:  All                      
      Cpu:  All                                      |  
-----------------------------------------------------+----------------------

Comment(by glynn):

 Replying to [ticket:1646 huhabla]:
 One way to get around the type issue is to define a call_with_catch
 function which is callable from Python, as described under
 [http://docs.python.org/extending/extending.htm Extending and Embedding
 the Python Interpreter]. The function would have the same signature as
 Python's apply() function, but would catch fatal errors and convert them
 to Python exceptions.

 If you only need coarse-grained fatal-error handling (e.g. calling exit
 handlers), then you don't need to wrap every function, just the script's
 main() function. Actually, you don't even need that; you can use the
 ctypes wrapper for G_add_error_handler(), just as a C module would.

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1646#comment:1>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list