Page MenuHomePhabricator

Changing config.verbose_output value in the middle of a script does not affect how warnings are printed
Closed, ResolvedPublic

Description

No idea how to get deprecate warnings printed. -debug option does not work (anymore?)

Event Timeline

Xqt triaged this task as Low priority.Feb 24 2016, 6:02 PM
Xqt raised the priority of this task from Low to High.Feb 24 2016, 6:12 PM

Seems this was deactivated with https://gerrit.wikimedia.org/r/187106 but there is no hint how to get warnings again. Neither -verbose nor -debug does it and I also didn't find anything in config file.

See also some remarks in T72970. I agree with Nullzero: Warnings should be showed always (default) and may be hidden by any settings.

Some scripts doesn't use handle_args to set debugging level. And where is the entry point for the shell?

For me deprecation warnings are printed in -verbose mode as expected, both in py2 and py3

Dalba changed the task status from Open to Stalled.Jan 7 2018, 3:53 PM
Dalba changed the status of subtask T132261: DeprecationWarning shown for Python 3 but not for Python 2 from Open to Stalled.
Dalba subscribed.

Works for me, too. I think we can close this task. @Xqt?

One sample:

>>> import pwb, pywikibot as py
>>> from pywikibot import config
>>> config.verbose_output = 2
>>> s = py.Site()
>>> p = py.User(s, '123.456.78.90')
>>> p.isRegistered()
False

expected behaviour:

>>> import pwb, pywikibot as py
>>> from pywikibot import config
>>> config.verbose_output = 2
>>> s = py.Site()
>>> p = py.User(s, '123.456.78.90')
>>> p.isRegistered()
WARNING: pywikibot\data\api.py:2371: DeprecationWarning: Instead of using kwargs from Request.__init__, parameters for the request to the API should be added via the "parameters" parameter.
  kwargs = self.request_class.clean_kwargs(kwargs)

WARNING: pywikibot\tools\ip.py:78: DeprecationWarning: ipaddress backport not available.
  warn('ipaddress backport not available.', DeprecationWarning)

WARNING: pywikibot\tools\ip.py:79: DeprecationWarning: page.ip_regexp is deprecated; use tools.ip.is_IP instead.
  if ip_regexp.match(IP) is None:

False
>>>
Xqt changed the task status from Stalled to Open.Jan 10 2018, 7:58 AM

My attempt, at least one of these is printed for me:

$ python pwb.py shell -verbose
Pywikibot rede13695872939f4cedbb139bd03ead318ef64cb
Python 3.6.4 (default, Dec 23 2017, 19:07:07) 
[GCC 7.2.1 20171128]
Welcome to the Pywikibot interactive shell!
>>> s=pywikibot.Site("cs")
>>> w=pywikibot.User(s, '123.456.78.90')
Found 1 wikipedia:cs processes running, including this one.
>>> w.isRegistered()
WARNING: /home/pavel/pywikibot/pywikibot/data/api.py:2371: DeprecationWarning: Instead of using kwargs from Request.__init__, parameters for the request to the API should be added via the "parameters" parameter.
  kwargs = self.request_class.clean_kwargs(kwargs)

False

My second attempt, still in verbose mode, it seems there is some conflict or incorrect behavior between config and actual output:

>>> from pywikibot import config
>>> config.verbose_output = 2
>>> w.isRegistered()
False
>>> config.verbose_output = 1
>>> w.isRegistered()
False
>>> config.verbose_output = 0
>>> w.isRegistered()
False

As it stands, you should add verbose_output = 2 to user-config.py or pass it as a parameter on command line. Otherwise it won't go through init_handlers which configures warning filters.

Dalba renamed this task from Deprecate warnings aren't printed to Changing config.verbose_output value in the middle of a script does not effect how warnings are printed.Jan 10 2018, 11:52 AM
Dalba renamed this task from Changing config.verbose_output value in the middle of a script does not effect how warnings are printed to Changing config.verbose_output value in the middle of a script does not affect how warnings are printed.

Change 403424 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] temporary for T127998

https://gerrit.wikimedia.org/r/403424

Change 403424 abandoned by Dalba:
temporary for T127998

Reason:
Fails on python 2. Did not check why.

https://gerrit.wikimedia.org/r/403424

Dalba removed Dalba as the assignee of this task.Jan 10 2018, 4:31 PM

Change 467411 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [doc] Update README-conversion.txt and explain debugging level

https://gerrit.wikimedia.org/r/467411

Change 467411 merged by jenkins-bot:
[pywikibot/core@master] [doc] Update README-conversion.txt and explain debugging level

https://gerrit.wikimedia.org/r/467411

Xqt claimed this task.