When importing pynotify I always get those nasty GTK-Warnings:
** (process:25512): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'
** (process:25512): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'
** (process:25512): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
The problem is, I don’t know how to suppress them, I tried:
>>> import sys
>>> from io import BytesIO
>>> sys.stderr = BytesIO()
>>> sys.stdout = BytesIO()
>>> print 's'
>>> import pynotify
** (process:25512): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'
** (process:25512): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'
** (process:25512): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
Doesn’t work, another thing I tried:
with warnings.catch_warnings():
warnings.simplefilter('error')
import pynotify
This also doesn’t help.
Seems like the GTK messages arrive on a different stderr. Any ideas how to suppress them?
To suppress these messages, you need to redirect stderr via its file descriptor:
Use of this function is as simple as: