Page MenuHomePhabricator

ModuleDeprecationWrapper doesn't show a deprecation warning as expected
Closed, ResolvedPublic

Description

try:

>>> import pwb, pywikibot as py
WARNING: pywikibot\tools\ip.py:74: ImportWarning: Importing ipaddr.IPAddress failed: No module named ipaddr
Importing ipaddress.ip_address failed: No module named ipaddress
Please install ipaddr 2.1.10+ or ipaddress.
>>> import catlib
>>> s = py.Site()
>>> c = catlib.Category(s, 'foo')
>>>

No deprecation warning is shown catlib.Category call

Event Timeline

Xqt triaged this task as Low priority.Jan 6 2018, 12:41 PM

Also no warning is shown for the given example:

from pywikibot.exceptions import UploadWarning

Or only in Python 2 like in T132261?

Change 402587 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] show deprecation warning

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

Change 402588 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] ModuleDeprecationWrapper._add_deprecated_attr: Delete existing attribute

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

@Dvorapa, I don't know about the other two tasks. They lack the information needed on how to reproduce the issue.

Change 402588 merged by jenkins-bot:
[pywikibot/core@master] ModuleDeprecationWrapper._add_deprecated_attr: Delete existing attribute

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

@Dalba You're right, there are no steps to reproduce given.

I believe this is fixed now. Feel free to reopen if not.

@Dalba What about this comment above:

Also no warning is shown for the given example:

from pywikibot.exceptions import UploadWarning

?

@Dalba What about this comment above:

Also no warning is shown for the given example:

from pywikibot.exceptions import UploadWarning

?

Works for me.

Note that in python 3.2+ DeprecationWarnings are ignored by default. One has to change the default filters either via the command line:

$ python -Wd::DeprecationWarning test_module.py

or from within the code:

from warnings import simplefilter
simplefilter('default', DeprecationWarning)
from pywikibot.exceptions import UploadWarning

I get only Warning: without any warning message.

I get only Warning: without any warning message.

Are you running the code in the interpreter prompt or are you executing a python module? Anyway, I think it's a different issue and is worth opening a new task for. But you may re-open this one if you think it's more appropriate.

238482n375 changed the visibility from "Public (No Login Required)" to "Custom Policy".
This comment was removed by Volans.
Volans changed the visibility from "Custom Policy" to "Public (No Login Required)".Jun 15 2018, 8:23 AM
Volans removed a project: acl*security.
Volans subscribed.
Volans unsubscribed.