Changeset 133

Show
Ignore:
Timestamp:
06/28/07 19:39:46 (2 years ago)
Author:
dsmith
Message:

supress wminput errors for nonexistent python plugins

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r131 r133  
    88        wminput 
    99        * rewrote ir_ptr plugin 
     10        * supress error for nonexistent python plugins 
    1011 
    11122007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 
  • trunk/wminput/py_plugin.c

    r128 r133  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-06-28 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * supress error for nonexistent python plugins 
     20 * 
    1821 *  2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * revised error messages 
     
    201204        PyObject *handle, *info; 
    202205        PyObject *PyStr; 
     206        PyObject *PyErrType, *PyErr, *PyTraceback; 
    203207 
    204208        if (!(PyStr = PyString_FromString(dir))) { 
     
    213217 
    214218        if (!(handle = PyImport_ImportModule(plugin->name))) { 
    215                 /* TODO: print only syntax errors, not "module not found errors" */ 
    216                 PyErr_Print(); 
     219                /* ignore "module not found" errors in top level module */ 
     220                PyErr_Fetch(&PyErrType, &PyErr, &PyTraceback); 
     221                PyErr_NormalizeException(&PyErrType, &PyErr, &PyTraceback); 
     222                if (PyErr_GivenExceptionMatches(PyErr, PyExc_ImportError) && 
     223                  !PyTraceback) { 
     224                        Py_XDECREF(PyErrType); 
     225                        Py_XDECREF(PyErr); 
     226                } 
     227                else { 
     228                        PyErr_Restore(PyErrType, PyErr, PyTraceback); 
     229                        PyErr_Print(); 
     230                } 
     231 
    217232                if (PySequence_DelItem(PyPath, 0)) { 
    218233                        PyErr_Print();