Re: logging in gi.repository import
- From: Simon Feltman <s feltman gmail com>
- To: Robert Schroll <rschroll gmail com>
- Cc: python-hackers-list gnome org
- Subject: Re: logging in gi.repository import
- Date: Mon, 5 Nov 2012 15:17:38 -0800
The logged error is unnecessary:
https://bugzilla.gnome.org/show_bug.cgi?id=687697
-Simon
On Mon, Nov 5, 2012 at 12:53 PM, Robert Schroll <rschroll gmail com> wrote:
> Hi all,
>
> Briefly: Why are import errors from gi.repository logged with logging.error?
> Isn't the ImportError enough of a clue that something went wrong?
>
> More detailed: I have an Python program that uses the Notify library,
> through pyGObject, as an optional dependency. I do the import something
> like this:
>>>> try:
> ... from gi.repository import Notify
> ... except ImportError:
> ... Notify = None
> If a user has pyGObject and Notify installed, it works fine. If they don't
> have pyGObject, it works fine. But if they have pyGObject but not Notify,
> they get an error message:
> ERROR:root:Could not find any typelib for Notify
> even though the program is working correctly. This message, I believe, is
> from the logging.error() call in importer.py.
>
> Now I can work around it in my case by adding
>>>> import logging
>>>> logging.disable(logging.ERROR)
> before trying to import from gi.repository. But if I were using the logging
> module in my program, I'd have to do a more complicated dance to turn the
> logging back on after the import. This seems silly. If this logging really
> is important, there should be a custom Logger object in gi.repository that I
> can adjust myself. But since the logging message is immediately followed by
> an ImportError, it seems completely redundant to me.
>
> If there's an easier way to suppress this message that I've missed, please
> point it out. Otherwise, please consider removing the logging.
>
> Thanks,
> Robert
> _______________________________________________
> python-hackers-list mailing list
> python-hackers-list gnome org
> https://mail.gnome.org/mailman/listinfo/python-hackers-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]