jenkins-bot merged this change.
[IMPR] use mw API IP/anon user detection
- also update dry_api_tests.py
Bug: T245318
Change-Id: Id8375873cf402aad1f9b971244973ec1eddd6d49
---
M pywikibot/data/api.py
M tests/dry_api_tests.py
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index a48110c..2c1262f 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -38,7 +38,7 @@
Error, TimeoutError, InvalidTitle, UnsupportedPage
)
from pywikibot.tools import (
- deprecated, itergroup, is_IP, PY2, PYTHON_VERSION,
+ deprecated, itergroup, PY2, PYTHON_VERSION,
getargspec, UnicodeType, remove_last_args
)
from pywikibot.tools.formatter import color_format
@@ -1253,7 +1253,7 @@
raise Error('API write action attempted without userinfo')
assert('name' in self.site._userinfo)
- if is_IP(self.site._userinfo['name']):
+ if 'anon' in self.site._userinfo:
raise Error('API write action attempted as IP %r'
% self.site._userinfo['name'])
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index a0f0b63..a9a03d3 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -248,7 +248,7 @@
Request, site=site,
parameters={'action': 'edit'})
- site._userinfo = {'name': '1.2.3.4', 'groups': []}
+ site._userinfo = {'name': '1.2.3.4', 'groups': [], 'anon': ''}
# unicode string with "u" is returned with Python 2
self.assertRaisesRegex(pywikibot.Error, " as IP u?'1.2.3.4'",
To view, visit change 572406. To unsubscribe, or for help writing mail filters, visit settings.