[mapserver-users] Python Mapscript MS 3.6.1

Sean Gillies sgillies at i3.com
Wed Jul 10 16:52:15 EDT 2002


Vinko Vrsalovic wrote:
 > Hello,
 >
 >     I've been trying to compile the mapscript python module, but I
 >     keep finding this errors:
 >
[snip]

Vinko,

One of your problems (regarding ms_error) occurs because the
mapscript.i included with mapserver 3.6.1 is a bit out-of-date.

Edit the Python specific section to match the following:

    #ifdef SWIGPYTHON
    // For Python, errors reported via the ms_error structure are translated
    // into RuntimeError exceptions. (Chris Chamberlin <cdc at aracnet.com>)
    %{
    static void _raise_ms_exception(void) {
        char errbuf[256];
        errorObj *ms_error = msGetErrorObj();
        snprintf(errbuf, 255, "%s: %s %s\n", ms_error->routine, 
msGetErrorString(ms_error->code), ms_error->message);
        _SWIG_exception(SWIG_RuntimeError, errbuf);
    }

    #define raise_ms_exception() { _raise_ms_exception(); return NULL; } 
      %}

    %except {
      $function
          errorObj *ms_error = msGetErrorObj();
        if ( (ms_error->code != MS_NOERR) && (ms_error->code != -1) )
          raise_ms_exception();
    }
    #endif // SWIGPYTHON

The key thing is to get an errorObj returned from msGetErrorObj().

Good luck!
Sean





More information about the mapserver-users mailing list