On Thu, 2002-05-16 at 22:42, Charles Waldman wrote:
>
> If you try to do GladeXML("somefile.glade") where "somefile.glade"
> does not exist or is not readable, you get a "WARNING: document is not
> well-formed" message. This error message is misleading; it does not
> lead one to the real cause of the problem. Hence this trivial patch:
>
> --- libglade.py.orig Thu May 16 16:32:26 2002
> +++ libglade.py Thu May 16 16:34:01 2002
> @@ -11,6 +11,8 @@
> class GladeXML(_gtk.GtkData):
> def __init__(self, filename=None, root=None, domain=None, _obj=None):
> if _obj: self._o = _obj; return
> + open(filename, 'r') ##raises an exception if file does not exist
> + close(filename) ## or is not readable
I would have thought the intention of the code would be more apparent
(i.e. no need for comment) if you said something like (untested):
if not os.path.exists(filename):
raise IOError, "No such file or directory: '%s'" % filename
In general, if you can re-write your code to make the comment redundant,
it's usually a good idea.
Cheers.
--
Graham Ashton
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/