Xqt created this task.
Xqt added projects: Pywikibot, Pywikibot-textlib.py.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION
**List of steps to reproduce and what happens**:
>>> import pywikibot
>>> from pywkibot.textlib import replace_links
>>> replace_links('foo', 'ba')
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
replace_links('foo', 'ba')
File "C:\pwb\GIT\core\pywikibot\textlib.py", line 664, in replace_links
replace_list[1] = pywikibot.Page(site, replace_list[1])
File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 2031, in __init__
super().__init__(source, title, ns)
File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 183, in __init__
raise Error(
pywikibot.exceptions.Error: Invalid argument type '<class 'NoneType'>' in
Page initializer: None
>>> replace_links('foo', None)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
replace_links('foo', None)
File "C:\pwb\GIT\core\pywikibot\textlib.py", line 673, in replace_links
raise ValueError('The "site" argument must be provided.')
ValueError: The "site" argument must be provided.
>>> replace_links('foo', 'ba')
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
replace_links('foo', 'ba')
File "C:\pwb\GIT\core\pywikibot\textlib.py", line 664, in replace_links
replace_list[1] = pywikibot.Page(site, replace_list[1])
File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 2031, in __init__
super().__init__(source, title, ns)
File "C:\pwb\GIT\core\pywikibot\page\__init__.py", line 183, in __init__
raise Error(
pywikibot.exceptions.Error: Invalid argument type '<class 'NoneType'>' in
Page initializer: None
>>> replace_links('foo', ['baz', False])
WARNING: <pyshell#11>:1: FutureWarning: site=None is deprecated for 2 years
and 8 months; use a valid site for list or tuple parameter "replace" instead.
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
replace_links('foo', ['baz', False])
File "C:\pwb\GIT\core\pywikibot\textlib.py", line 675, in replace_links
linktrail = site.linktrail()
AttributeError: 'NoneType' object has no attribute 'linktrail'
Anyway it never passes because site.linktrail is used in line 675 but no site
object is created if the parameter is None. The deprecation warning is not
usefull
**What should have happened instead?**:
A site object should always be passes to the function i.e. site parameter
should be mandatory
**Software version**:
Pywikibot 3.0.20190430+
TASK DETAIL
https://phabricator.wikimedia.org/T294649
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Xqt
Cc: Aklapper, Dvorapa, Xqt, pywikibot-bugs-list, Jyoo1011, JohnsonLee01, SHEKH,
Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS, Mdupont, JJMC89,
Altostratus, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]