GNOME Bugzilla – Bug 310666
gimp.parasite_find() should not error out on not found
Last modified: 2005-07-17 19:48:04 UTC
A quite old script of mine [1] is broken in a strange way by currents cvs's gimp.parasite_find() which returns NULL for not found. AFAIK it used to return an empty parasite before, see : http://cvs.gnome.org/viewcvs/gimp/plug-ins/pygimp/gimpmodule.c?r1=1.32&r2=1.33 The two uses produce different errors, both not very pythonesque ;) try : sDefaultPath = gimp.parasite_find("pdb2doc-outpath").data except : print "gimp.parasite_find failed!" if sDefaultPath is None : return os.environ['HOME'] gives : LibGimpBase-ERROR **: could not find handler for message: 5 aborting... while : if gimp.parasite_find("pdb2doc-outpath") : gimp.parasite_detach("pdb2doc-outpath") gives : Traceback (most recent call last):
+ Trace 61803
dialog.res = run_script(params)
return apply(function, params)
if gimp.parasite_find("pdb2doc-outpath") : gimp.error: could not find parasite 'pdb2doc-outpath'
[1] http://hans.breuer.org/gimp/default.htm
On retrospect, the old behavior of returning None instead of throwing an exception makes more sense: 2005-07-17 Manish Singh <yosh@gimp.org> * plug-ins/pygimp/gimpmodule.c * plug-ins/pygimp/pygimp-drawable.c: revert to old behavior of parasite_find functions returning None when there isn't a parasite found. Fixed bug #310666.
Your first error is coming from GIMP itself, you're not allowed to call the parasite functions from the query() function. This hasn't worked in any GIMP, and has nothing to do with python.