After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 310666 - gimp.parasite_find() should not error out on not found
gimp.parasite_find() should not error out on not found
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Gimp-Python
git master
Other All
: Normal normal
: ---
Assigned To: Manish Singh
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2005-07-17 18:54 UTC by Hans Breuer
Modified: 2005-07-17 19:48 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Hans Breuer 2005-07-17 18:54:54 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):
  • File "/opt/lib/gimp/2.0/python/gimpfu.py", line 503 in response
    dialog.res = run_script(params)
  • File "/opt/lib/gimp/2.0/python/gimpfu.py", line 269 in run_script
    return apply(function, params)
  • File "/home/hb/.gimp-2.3/plug-ins/pdb2doc.py", line 404 in python_pdbtodoc
    if gimp.parasite_find("pdb2doc-outpath") : gimp.error: could not find parasite 'pdb2doc-outpath'
 
[1] http://hans.breuer.org/gimp/default.htm
Comment 1 Manish Singh 2005-07-17 19:47:01 UTC
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.
Comment 2 Manish Singh 2005-07-17 19:48:04 UTC
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.