Bug 1330651 - python-astrid doesn't ignore PyGIWarning warnings
Summary: python-astrid doesn't ignore PyGIWarning warnings
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-astroid
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Brian Lane
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-26 16:26 UTC by Giuseppe Scrivano
Modified: 2016-04-27 21:47 UTC (History)
2 users (show)

Fixed In Version: python-astroid-1.4.5-2.fc25
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-04-27 21:47:40 UTC
Type: Bug


Attachments (Terms of Use)

Description Giuseppe Scrivano 2016-04-26 16:26:30 UTC
Description of problem:

pylint doesn't ignore PyGIWarning warnings

Version-Release number of selected component (if applicable):

python-astroid 1.4.5-1.fc25

How reproducible:

100%

Steps to Reproduce:
Try pylint on the https://github.com/projectatomic/atomic.git source base

Actual results:

/usr/lib/python2.7/site-packages/astroid/brain/brain_gi.py:136: PyGIWarning: OSTree was imported without specifying a version first. Use gi.require_version('OSTree', '1.0') before import to ensure that the right version gets loaded.



Expected results:

not raising any warning

Additional info:

This patch fixed the problem for me:

--- /usr/lib/python2.7/site-packages/astroid/brain/brain_gi.py	2016-03-21 18:23:46.000000000 +0000
+++ /usr/lib/python2.7/site-packages/astroid/brain/brain_gi_new.py	2016-04-26 16:16:42.657432435 +0000
@@ -133,16 +133,17 @@
             modcode = ''
             for m in itertools.chain(modnames, optional_modnames):
                 try:
-                    __import__(m)
                     with warnings.catch_warnings():
                         # Just inspecting the code can raise gi deprecation
                         # warnings, so ignore them.
                         try:
-                            from gi import PyGIDeprecationWarning
+                            from gi import PyGIDeprecationWarning, PyGIWarning
                             warnings.simplefilter("ignore", PyGIDeprecationWarning)
+                            warnings.simplefilter("ignore", PyGIWarning)
                         except Exception:
                             pass
 
+                        __import__(m)
                         modcode += _gi_build_stub(sys.modules[m])
                 except ImportError:
                     if m not in optional_modnames:

Comment 1 Brian Lane 2016-04-26 23:17:18 UTC
Thanks! Could you also submit your patch upstream at: https://github.com/PyCQA/astroid

Comment 2 Giuseppe Scrivano 2016-04-27 13:14:39 UTC
pull request here:

https://github.com/PyCQA/astroid/pull/333


Note You need to log in before you can comment on or make changes to this bug.