how to silence warnings

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how to silence warnings

Marco Prosperi

hello, is there some way to silence deprecationwarnings in a wxpython app? for example those showing up in stdout from wx.lib.plot  as
wx\lib\plot\utils.py:255: PendingDeprecationWarning: `GetEnablePointLabel` is pending deprecation. Please use `self.enablePointLabel property` instead.

but also originating by other libraries I use. I redirect stdout to a textctrl

I should silence warnings from python code, not from python.exe command line

I've found this on SO but doesn't seem to work:

import warnings
warnings.filterwarnings("ignore")

I use win10, python 3.5-64, wxpython 4.0.1

thanks in advance for hints
Marco

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to silence warnings

nepix32

Try this ("wrapping" the offending code part):

        # create your canvas
        panel
= wxplot.PlotCanvas(self)
       
       
import warnings
       
       
with warnings.catch_warnings():
            warnings
.filterwarnings('ignore', category=PendingDeprecationWarning)

            panel
.GetEnablePointLabel()

You can "wrap" the whole app that way.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to silence warnings

Marco Prosperi

thank you, it works. I've changend
warnings.filterwarnings('ignore', category=PendingDeprecationWarning)

with

warnings.simplefilter('ignore')

to catch both deprecation warnings and pending deprecation warnings (and others)

Marco



On Friday, June 15, 2018 at 3:11:22 PM UTC+2, nepix32 wrote:

Try this ("wrapping" the offending code part):

        # create your canvas
        panel
= wxplot.PlotCanvas(self)
       
       
import warnings
       
       
with warnings.catch_warnings():
            warnings
.filterwarnings('ignore', category=PendingDeprecationWarning)

            panel
.GetEnablePointLabel()

You can "wrap" the whole app that way.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to silence warnings

GadgetSteve
I would like to wade in and point out that you should only turn off
deprecation, and other, warnings in release code, (not test or
development), and the real fix is to actually address the warnings.
Failure to address deprecation warnings will eventually result in a
sudden rush of errors (when the deprecated facility is removed) and
other warnings are normally a sign of something potentially going wrong.

In my experience suppressing warnings always bites you somewhere painful
sooner or later and usually at the worst moment in time. It certainly
has worked out that way for me.

Steve

On 16/06/2018 08:04, Marco Prosperi wrote:

>
> thank you, it works. I've changend
> |warnings.filterwarnings('ignore',category=PendingDeprecationWarning)|
> |
> |
> with
> |
> |
> ||warnings.simplefilter('ignore')
> ||
>
> to catch both deprecation warnings and pending deprecation warnings (and
> others)
>
> Marco
>
>
>
> On Friday, June 15, 2018 at 3:11:22 PM UTC+2, nepix32 wrote:
>
>
>     Try this ("wrapping" the offending code part):
>
>     |
>     # create your canvas
>              panel =wxplot.PlotCanvas(self)
>
>     importwarnings
>
>     withwarnings.catch_warnings():
>                
>     warnings.filterwarnings('ignore',category=PendingDeprecationWarning)
>
>                  panel.GetEnablePointLabel()
>     |
>
>     You can "wrap" the whole app that way.
>
> --
> You received this message because you are subscribed to the Google
> Groups "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> For more options, visit https://groups.google.com/d/optout.

--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.

---
This email has been checked for viruses by AVG.
https://www.avg.com

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to silence warnings

Marco Prosperi

I agree, this is my actual code

if main_is_frozen():
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        run()
else:
    run()

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.