Xqt created this task.
Xqt added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION
____________ TestWikibaseWriteGeneral.test_edit_entity_new_property
____________
func = <function WikibasePage.editEntity at 0x7f04aa9ab560>
self = PropertyPage('Property:-1')
args = ({'descriptions': {'en': {'language': 'en', 'value': 'Pywikibot test
new property - 1718172266.6584291'}}, 'labels': {'en': {'language': 'en',
'value': 'Pywikibot test new property'}}},)
kwargs = {}, do_async = False, callback = None
err = APIError("failed-save", "The save has failed.", {'param':
'new=property&action=wbeditentity&bot=1&data=%7B%22labels%22...postorius/lists/mediawiki-api-announce.lists.wikimedia.org/>
for notice of API deprecations and breaking changes.'})
link = '[[wikidata:test:Property:-1]]'
def handle(func, self, *args, **kwargs):
do_async = kwargs.pop('asynchronous', False)
callback = kwargs.pop('callback', None)
err = None
try:
> func(self, *args, **kwargs)
pywikibot/page/_decorators.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _
pywikibot/page/_wikibase.py:812: in editEntity
super().editEntity(data, **kwargs)
pywikibot/page/_wikibase.py:326: in editEntity
self, data, baserevid=baserevid, **kwargs)
pywikibot/site/_decorators.py:93: in callee
return fn(self, *args, **kwargs)
pywikibot/site/_datasite.py:328: in editEntity
return req.submit()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _
self =
pywikibot.data.api._requests.Request<wikidata:test->'/w/api.php?new=property&action=wbeditentity&bot=1&data={"labels":...6.6584291"}},+"datatype":+"string"}&assert=user&maxlag=5&format=json&token=c59b754766064550ef58d8f65fa521f866693a11+\'>
def submit(self) -> dict:
"""Submit a query and parse the response.
.. versionchanged:: 8.0.4
in addition to *readapidenied* also try to login when API
response is *notloggedin*.
.. versionchanged:: 9.0
Raise :exc:`exceptions.APIError` if the same error comes
twice in a row within the loop.
:return: a dict containing data retrieved from api.php
"""
self._add_defaults()
use_get = self._use_get()
retries = 0
self.last_error = dict.fromkeys(['code', 'info'])
while True:
paramstring = self._http_param_string()
simulate = self._simulate(self.action)
if simulate:
return simulate
if self.throttle:
self.site.throttle(write=self.write)
else:
pywikibot.log(
f"Submitting unthrottled action '{self.action}'.")
use_get, uri, body, headers = self._get_request_params(use_get,
paramstring)
response, use_get = self._http_request(use_get, uri, body,
headers,
paramstring)
if response is None:
continue
result = self._json_loads(response)
if result is None:
continue
if self._userinfo_query(result):
continue
if self._handle_warnings(result):
continue
if 'error' not in result:
return result
error = result['error']
for key in result:
if key in ('error', 'warnings'):
continue
assert key not in error
error[key] = result[key]
if '*' in error:
# help text returned
error['help'] = error.pop('*')
code = error.setdefault('code', 'Unknown')
info = error.setdefault('info', None)
if (code == self.last_error['code']
and info == self.last_error['info']):
raise pywikibot.exceptions.APIError(**self.last_error)
self.last_error = error
if not self._logged_in(code):
continue
if code == 'maxlag':
retries += 1
if retries > max(5, pywikibot.config.max_retries):
break
pywikibot.log('Pausing due to database lag: ' + info)
try:
lag = error['lag']
except KeyError:
lag = lagpattern.search(info)
lag = float(lag['lag']) if lag else 0.0
self.site.throttle.lag(lag * retries)
# reset last error
self.last_error = dict.fromkeys(['code', 'info'])
continue
if code == 'help' and self.action == 'help':
# The help module returns an error result with the complete
# API information. As this data was requested, return the
# data instead of raising an exception.
return {'help': {'mime': 'text/plain',
'help': error['help']}}
pywikibot.warning(f'API error {code}: {info}')
pywikibot.log(f' headers=\n{response.headers}')
if self._internal_api_error(code, error.copy(), result):
continue
# Phab. tickets T48535, T64126, T68494, T68619
if code == 'failed-save' \
and self._is_wikibase_error_retryable(error):
self.wait()
continue
if code == 'ratelimited':
self._ratelimited()
continue
# If notloggedin or readapidenied is returned try to login
if code in ('notloggedin', 'readapidenied') \
and self.site._loginstatus in (LoginStatus.NOT_ATTEMPTED,
LoginStatus.NOT_LOGGED_IN):
self.site.login()
continue
if self._bad_token(code):
continue
if 'mwoauth-invalid-authorization' in code:
msg = f'OAuth authentication for {self.site}: {info}'
if 'Nonce already used' in info:
pywikibot.error(f'Retrying failed {msg}')
continue
raise NoUsernameError(f'Failed {msg}')
if code == 'cirrussearch-too-busy-error': # T170647
self.wait()
continue
if code in ('search-title-disabled', 'search-text-disabled'):
prefix = 'gsr' if 'gsrsearch' in self._params else 'sr'
del self._params[prefix + 'what']
# use intitle: search instead
if code == 'search-title-disabled' \
and self.site.has_extension('CirrusSearch'):
key = prefix + 'search'
self._params[key] = ['intitle:' + search
for search in self._params[key]]
continue
if code == 'urlshortener-blocked': # T244062
# add additional informations to error dict
error['current site'] = self.site
if self.site.user():
error['current user'] = self.site.user()
else: # not logged in; show the IP
uinfo = self.site.userinfo
error['current user'] = uinfo['name']
# raise error
try:
param_repr = str(self._params)
pywikibot.log(
f'API Error: query=\n{pprint.pformat(param_repr)}')
pywikibot.log(f' response=\n{result}')
args = {'param': body} if body else {}
args.update(error)
> raise pywikibot.exceptions.APIError(**args)
E pywikibot.exceptions.APIError: failed-save: The save has
failed.
E [param:
new=property&action=wbeditentity&bot=1&data=%7B%22labels%22%3A+%7B%22en%22%3A+%7B%22language%22%3A+%22en%22%2C+%22value%22%3A+%22Pywikibot+test+new+property%22%7D%7D%2C+%22descriptions%22%3A+%7B%22en%22%3A+%7B%22language%22%3A+%22en%22%2C+%22value%22%3A+%22Pywikibot+test+new+property+-+1718172266.6584291%22%7D%7D%2C+%22datatype%22%3A+%22string%22%7D&assert=user&maxlag=5&format=json&token=c59b754766064550ef58d8f65fa521f866693a11%2B%5C;
E messages: [{'name': 'wikibase-api-failed-save',
'parameters': [], 'html': {'*': 'The save has failed.'}}, {'name':
'wikibase-validator-label-conflict', 'parameters': ['Pywikibot test new
property', 'en', '[[Property:P93593|P93593]]'], 'html': {'*': 'Property <a
href="/wiki/Property:P93593" title="Property:P93593">P93593</a> already has
label "Pywikibot test new property" associated with language code en.'}}];
E servedby: mw-api-ext.eqiad.main-778c97d8cb-vcslj;
E help: See https://test.wikidata.org/w/api.php for API
usage. Subscribe to the mediawiki-api-announce mailing list at
<https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/>
for notice of API deprecations and breaking changes.]
pywikibot/data/api/_requests.py:1122: APIError
During handling of the above exception, another exception occurred:
self = <tests.wikibase_edit_tests.TestWikibaseWriteGeneral
testMethod=test_edit_entity_new_property>
def test_edit_entity_new_property(self):
"""Test creating a new property using
``PropertyPage.editEntity``."""
testsite = self.get_repo()
ts = str(time.time())
data = {
'labels': {
'en': {
'language': 'en',
'value': 'Pywikibot test new property',
}
},
'descriptions': {
'en': {
'language': 'en',
'value': 'Pywikibot test new property - ' + ts,
}
}
}
prop = pywikibot.PropertyPage(testsite, datatype='string')
> prop.editEntity(data)
tests/wikibase_edit_tests.py:182:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _
pywikibot/page/_decorators.py:52: in wrapper
handle(func, self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _
func = <function WikibasePage.editEntity at 0x7f04aa9ab560>
self = PropertyPage('Property:-1')
args = ({'descriptions': {'en': {'language': 'en', 'value': 'Pywikibot test
new property - 1718172266.6584291'}}, 'labels': {'en': {'language': 'en',
'value': 'Pywikibot test new property'}}},)
kwargs = {}, do_async = False, callback = None
err = APIError("failed-save", "The save has failed.", {'param':
'new=property&action=wbeditentity&bot=1&data=%7B%22labels%22...postorius/lists/mediawiki-api-announce.lists.wikimedia.org/>
for notice of API deprecations and breaking changes.'})
link = '[[wikidata:test:Property:-1]]'
def handle(func, self, *args, **kwargs):
do_async = kwargs.pop('asynchronous', False)
callback = kwargs.pop('callback', None)
err = None
try:
func(self, *args, **kwargs)
# TODO: other "expected" error types to catch?
except Error as edit_err:
err = edit_err # edit_err will be deleted in the end of the
scope
link = self.title(as_link=True)
if do_async:
pywikibot.error(f'page {link} not saved due to {err}\n')
pywikibot.log(f'Error saving page {link} ({err})\n',
exc_info=True)
if not callback and not do_async:
if isinstance(err, PageSaveRelatedError):
raise err
> raise OtherPageSaveError(self, err)
E pywikibot.exceptions.OtherPageSaveError: Edit to page
[[wikidata:test:Property:-1]] failed:
E failed-save: The save has failed.
E [param:
new=property&action=wbeditentity&bot=1&data=%7B%22labels%22%3A+%7B%22en%22%3A+%7B%22language%22%3A+%22en%22%2C+%22value%22%3A+%22Pywikibot+test+new+property%22%7D%7D%2C+%22descriptions%22%3A+%7B%22en%22%3A+%7B%22language%22%3A+%22en%22%2C+%22value%22%3A+%22Pywikibot+test+new+property+-+1718172266.6584291%22%7D%7D%2C+%22datatype%22%3A+%22string%22%7D&assert=user&maxlag=5&format=json&token=c59b754766064550ef58d8f65fa521f866693a11%2B%5C;
E messages: [{'name': 'wikibase-api-failed-save',
'parameters': [], 'html': {'*': 'The save has failed.'}}, {'name':
'wikibase-validator-label-conflict', 'parameters': ['Pywikibot test new
property', 'en', '[[Property:P93593|P93593]]'], 'html': {'*': 'Property <a
href="/wiki/Property:P93593" title="Property:P93593">P93593</a> already has
label "Pywikibot test new property" associated with language code en.'}}];
E servedby: mw-api-ext.eqiad.main-778c97d8cb-vcslj;
E help: See https://test.wikidata.org/w/api.php for API
usage. Subscribe to the mediawiki-api-announce mailing list at
<https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/>
for notice of API deprecations and breaking changes.]
pywikibot/page/_decorators.py:44: OtherPageSaveError
TASK DETAIL
https://phabricator.wikimedia.org/T367323
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Xqt
Cc: 813gan, Aklapper, Xqt, pywikibot-bugs-list, mevo, PotsdamLamb, Jyoo1011,
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Aram, Viztor, Wenyi, Tbscho,
MayS, Mdupont, JJMC89, Dvorapa, Altostratus, binbot, Avicennasis, mys_721tx,
jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]