Xqt created this task.
Xqt added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION
    _____________________________ TestUpload.test_png 
______________________________
    
    self = <tests.upload_tests.TestUpload testMethod=test_png>
    
        def test_png(self):
            """Test uploading a png using Site.upload."""
            page = pywikibot.FilePage(self.site, 'MP_sounds-pwb.png')
            self.site.upload(page, source_filename=self.sounds_png,
                             comment='pywikibot test',
    >                        ignore_warnings=True)
    
    tests/upload_tests.py:39: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
    pywikibot/site/_decorators.py:93: in callee
        return fn(self, *args, **kwargs)
    pywikibot/site/_apisite.py:3023: in upload
        return Uploader(self, filepage, **kwargs).upload()
    pywikibot/site/_upload.py:134: in upload
        return self._upload(self.ignore_warnings, self.report_success)
    pywikibot/site/_upload.py:439: in _upload
        report_success, file_key)
    pywikibot/site/_upload.py:457: in submit
        result = request.submit()['upload']
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
    
    self = 
pywikibot.data.api._requests.Request<wikipedia:test->'/w/api.php?action=upload&text=pywikibot+test&filename=MP+sounds-...ment=pywikibot+test&assert=user&ignorewarnings=&maxlag=5&format=json&token=f71d55ad3eaf00649aefe1e64ffecf3c666939bd+\'>
    
        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: fileexists-no-change: The 
upload is an exact duplicate of the current version of [[:File:MP 
sounds-pwb.png]].
    E               [param: 
b'--===============2637916737836971067==\nContent-Type: 
text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="action"\n\nupload\n--===============2637916737836971067==\nContent-Type: 
text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="token"\n\nf71d55ad3eaf00649aefe1e64ffecf3c666939bd+\\\n--===============2637916737836971067==\nContent-Type:
 text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="text"\n\npywikibot 
test\n--===============2637916737836971067==\nContent-Type: 
text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="filename"\n\nMP 
sounds-pwb.png\n--===============2637916737836971067==\nContent-Type: 
text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="comment"\n\npywikibot 
test\n--===============2637916737836971067==\nContent-Type: 
text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="assert"\n\nuser\n--===============2637916737836971067==\nContent-Type: 
text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="ignorewarnings"\n\n\n--===============2637916737836971067==\nContent-Type:
 text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="maxlag"\n\n5\n--===============2637916737836971067==\nContent-Type: 
text/plain\nMIME-Version: 1.0\nContent-disposition: form-data; 
name="format"\n\njson\n--===============2637916737836971067==\nContent-Type: 
image/png\nMIME-Version: 1.0\nContent-disposition: form-data; name="file"; 
filename="FAKE-NAME"\nContent-Transfer-Encoding: 
binary\n\n\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x18\x00\x00\x00\x1b\x08\x06\x00\x00\x00f\xe3OV\x00\x00\x00\x06bKGD\x00\xf6\x00\xf6\x00\xf6\xdb\xa0F\xc9\x00\x00\x04\xb1IDATx^\xedVKL\xa3U\x14\xbe\xbd\xfdi\xa1\x0f\xfa@\n\xe1Q0\xe5\x91\t0\xb1X\x11u\x01!qA\x02\x9b\x99\xd1\x85\xc1\x98qa\x82\xc9,\x94d\x94\x05!l$3\x91\xd4D\xb62\x99q\xa2\x1b\x13\xd4\xb8
 
3\x89\x19p1\x134Aq\xa4\x8eNk\x80\xf2\x9a>hK\xa1\xed\xd0\x87\xdf\xf7O\xff\xb8sg\xdc\xccIN\xee\xeb\xfc\xdf9\xe7;\xe7\xdeVW*\x95\xc4\x7f)\x12\xfa\xd4\xc1\xbf\x8b\xddn\x17R\xfe\xe3\xc7d2\x99].\xd7\xac\xcf\xf7|\xc0\xe7\xf3\xfdZWW\xf7aUU\x95\xa2\x9d;\x1c\x0e\xd1\xd8\xd8(,\x16\x8b\xa0\xb8\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b5X\xc43B\xfb34\xc3\xfa>\xbb\x0e\x91;YBd\x11\xd5\xb3\xff\xa1\x8fq\xc5\xbf\x83\xb3\x0bx\x8f\\\xe4\xfd\xe8\xe8H\xcb@uv\xf7\xee\xbd;\x1b\x1b\x1b\x1f\x03\xa4\x06\xd9\x0c\xc1\xe6k\x8c\xcb\xed\xed\xedlM:,Ao655\xe5\x10\x90\x8fw\x02x\xf7$\xbb\x86N0\x16WVVf\x97\x96\x96\xc4\x93($\xb9W\x7f/\xe2\xf18\xcf>*\xbf\xa2\x11\xec_\x82~\xd9\xd6\xd6F\xea\x9e\x83\x83.\xdc\xe0\x1f\x80\x93\xc4}\xb2\x00\xbc\x0e\x1a\xc5+p(\xb5\x0b\xc5\x82\xa2e\xbf\x98\x9b\x9b\xbbv\xfb\xf6-\xf4\xbc\xc4Sm\x16\x07\x07\xfbbaa\xe1\n\x00\xbe\xa7-\x95\xb6x\x1cEss3\xeb\xb1\x89\xf5\'\xa0\xe9\x1bdJ\x8c6\xd8T\x83\xc6\x87lSE\xbb\\T\xa6\t\xe3q\xbf\xdf\x1fv\xbb[^\x83a~ss\xf3\x1a\xba\xc7\xcf\xae\xa2\xb0\x85\xe9\x84\xd9\xd1\x11\xe4\x11\xc6G\xac\x05\xe8\xe1\xbe\x05\xba\x0f}@\xbb\xff\xffo\xcbS\x07\x7f\x03,\x11\x9a\xfa\xd7\xd7\xeb\x8a\x00\x00\x00\x00IEND\xaeB`\x82\n--===============2637916737836971067==--\n';
    E                stasherrors: [{'message': 'uploadstash-exception', 
'params': ['UploadStashBadPathException', "Path doesn't exist."], 'code': 
'uploadstash-exception', 'type': 'error'}];
    E                servedby: mw-api-ext.eqiad.main-778c97d8cb-qp95t;
    E                help: See https://test.wikipedia.org/w/api.php for API 
usage. Subscribe to the mediawiki-api-announce mailing list at 
&lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt;
 for notice of API deprecations and breaking changes.]
    
    pywikibot/data/api/_requests.py:1122: APIError

TASK DETAIL
  https://phabricator.wikimedia.org/T367319

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Xqt
Cc: Aklapper, pywikibot-bugs-list, jayvdb, Xqt, mevo, PotsdamLamb, Jyoo1011, 
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Aram, Viztor, Wenyi, Tbscho, 
MayS, Mdupont, JJMC89, Dvorapa, Altostratus, binbot, Avicennasis, mys_721tx, 
Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to