]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf scripts python: exported-sql-viewer.py: Fix warning display
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 21 May 2021 09:20:53 +0000 (12:20 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 21 May 2021 19:31:07 +0000 (16:31 -0300)
Deprecation warnings are useful only for the developer, not an end user.
Display warnings only when requested using the python -W option. This
stops the display of warnings like:

 tools/perf/scripts/python/exported-sql-viewer.py:5102: DeprecationWarning:
         an integer is required (got type PySide2.QtCore.Qt.AlignmentFlag).
         Implicit conversion to integers using __int__ is deprecated, and
         may be removed in a future version of Python.
    err = app.exec_()

Since the warning can be fixed only in PySide2, we must wait for it to
be finally fixed there.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org # v5.3+
Link: http://lore.kernel.org/lkml/20210521092053.25683-4-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/scripts/python/exported-sql-viewer.py

index 4a63843f623c4086e64964114f6fb365bc43e854..711d4f9f5645cf33aa721f7c8a263a6b2d691305 100755 (executable)
 from __future__ import print_function
 
 import sys
+# Only change warnings if the python -W option was not used
+if not sys.warnoptions:
+       import warnings
+       # PySide2 causes deprecation warnings, ignore them.
+       warnings.filterwarnings("ignore", category=DeprecationWarning)
 import argparse
 import weakref
 import threading