Xover created this task.
Xover added a project: Pywikibot.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION
  In current HEAD (PWB pre-7.0), imagetransfer.py triggers a Python `KeyError` 
in site/_apisite.py:upload.create_warnings_list() when ignore_warnings is true. 
The cause seems to be that create_warnings_list() is looking for an `offset` 
entry in the passed-in `response` dict which is (no longer?) being set for that 
code path instead of the `_offset` argument passed in through upload()s 
signature.
  
    ❯ python3 pwb.py imagetransfer -lang:commons -family:commons 
"File:filename.jpg" -tolang:en -tofamily:wikisource -force_if_shared
    ------------------------------------------------------------
    0. Found image: [[File:filename.jpg]]
    =={{int:filedesc}}==
    …
    ============================================================
    
    >>> Transfer [[commons:File:filename.jpg]] from commons:commons to 
wikisource:en
    
    URL should be: 
https://upload.wikimedia.org/wikipedia/commons/b/b4/filename.jpg
    
    The filename on the target wiki will default to: filename.jpg
    
    Enter a better name, or press enter to accept: 
    The suggested description is: …
    
    Do you want to change this description? ([y]es, [N]o, [q]uit): 
    Uploading file to wikisource:en...
    ERROR: Upload error: 
    Traceback (most recent call last):
      File "…pywikibot/specialbots/_upload.py", line 413, in upload_file
        success = imagepage.upload(file_url,
      File "…pywikibot/page/__init__.py", line 2456, in upload
        return self.site.upload(self, source_filename=filename, source_url=url,
      File "…pywikibot/site/_decorators.py", line 92, in callee
        return fn(self, *args, **kwargs)
      File "…pywikibot/site/_apisite.py", line 2968, in upload
        if ignore_warnings(create_warnings_list(result)):
      File "…pywikibot/site/_apisite.py", line 2595, in create_warnings_list
        return [
      File "…pywikibot/site/_apisite.py", line 2599, in <listcomp>
        _file_key, response['offset'])
    KeyError: 'offset'
    1 pages read
    0 pages written
    0 pages skipped
    Execution time: 14 seconds
    Read operation time: 14.0 seconds
    Script terminated successfully.
  
  The immediate fix is to use `_offset` instead of `response['offset']` there, 
but these are not going to be identical, and it is possible this will cause 
problems in other code paths. From what I can tell from `git blame`, I conclude 
that this is the correct variable to use and any other code paths that break as 
a result should instead be fixed to update `_offset`. Someone that knows the 
code better will have to make that call though.

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

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

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

Reply via email to