Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform MW deprecation warnings into python DeprecationWarning #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions mwclient/client.py
Expand Up @@ -307,8 +307,21 @@ def handle_api_result(self, info, kwargs=None, sleeper=None):
self.logged_in = 'anon' not in userinfo
if 'warnings' in info:
for module, warning in info['warnings'].items():
if '*' in warning:
log.warning(warning['*'])
msg = warning.get('*')
if not msg:
continue
if (
'is deprecated' in msg
or (
module == 'main'
and 'Subscribe to the mediawiki-api-announce mailing' in msg
)
):
# try to avoid fake warnings which are just deprecation warnings
# to keep logs cleans and usefull
warnings.warn(msg, DeprecationWarning)
else:
log.warning(msg)

if 'error' in info:
if info['error'].get('code') in {u'internal_api_error_DBConnectionError',
Expand Down