JJMC89 added a comment.

  In T261050#6465754 <https://phabricator.wikimedia.org/T261050#6465754>, @Xqt 
wrote:
  
  > I guess after T263010 <https://phabricator.wikimedia.org/T263010> is merged 
this error should write `'Login status: IN_PROGRESS'` into the logfile every 
time. @Multichill could you confirm?
  
  Confirmed
  
  ----
  
  The bot having a login status of `IN_PROGRESS` (`LoginStatus(-2)`) when 
editing while logged in doesn't seem right. (see t.py below, configured with 
OAuth)
  In this case, _bad_token('badtoken') 
<https://github.com/wikimedia/pywikibot/blob/9c88a054a91fc3d8ac58c214f024b33f78c8f7c7/pywikibot/data/api.py#L1837>
 would return `False` early 
<https://github.com/wikimedia/pywikibot/blob/9c88a054a91fc3d8ac58c214f024b33f78c8f7c7/pywikibot/data/api.py#L1693-L1696>
 instead of handling the bad token when the API gives a `badtoken` response.
  
    $ python3 -m pip install -U pip setuptools wheel
    Collecting pip
      Downloading pip-22.0.2-py3-none-any.whl (2.1 MB)
         |████████████████████████████████| 2.1 MB 12.5 MB/s
    Collecting setuptools
      Downloading setuptools-60.6.0-py3-none-any.whl (953 kB)
         |████████████████████████████████| 953 kB 10.9 MB/s
    Collecting wheel
      Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
    Installing collected packages: pip, setuptools, wheel
      Attempting uninstall: pip
        Found existing installation: pip 20.2.3
        Uninstalling pip-20.2.3:
          Successfully uninstalled pip-20.2.3
      Attempting uninstall: setuptools
        Found existing installation: setuptools 49.2.1
        Uninstalling setuptools-49.2.1:
          Successfully uninstalled setuptools-49.2.1
    Successfully installed pip-22.0.2 setuptools-60.6.0 wheel-0.37.1
    $ python3 -m pip install -e .[mwoauth,mwparserfromhell]
    Obtaining file:///home/jjmc89/wrk/pwb
      Preparing metadata (setup.py) ... done
    Collecting requests>=2.20.1
      Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
    Requirement already satisfied: setuptools>=38.5.2 in 
/home/jjmc89/.pyenv/versions/3.9.2/envs/pwb-39/lib/python3.9/site-packages 
(from pywikibot==7.0.0.dev0) (60.6.0)
    Collecting mwoauth!=0.3.1,>=0.2.4
      Using cached mwoauth-0.3.7-py3-none-any.whl (13 kB)
    Collecting mwparserfromhell>=0.5.0
      Using cached 
mwparserfromhell-0.6.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl 
(177 kB)
    Collecting PyJWT<2.0.0,>=1.0.1
      Using cached PyJWT-1.7.1-py2.py3-none-any.whl (18 kB)
    Collecting six
      Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
    Collecting oauthlib
      Downloading oauthlib-3.2.0-py3-none-any.whl (151 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.5/151.5 KB 8.5 MB/s eta 
0:00:00
    Collecting requests-oauthlib
      Downloading requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)
    Collecting idna<4,>=2.5
      Using cached idna-3.3-py3-none-any.whl (61 kB)
    Collecting certifi>=2017.4.17
      Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
    Collecting urllib3<1.27,>=1.21.1
      Using cached urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
    Collecting charset-normalizer~=2.0.0
      Downloading charset_normalizer-2.0.11-py3-none-any.whl (39 kB)
    Installing collected packages: PyJWT, certifi, urllib3, six, oauthlib, 
mwparserfromhell, idna, charset-normalizer, requests, requests-oauthlib, 
pywikibot, mwoauth
      Running setup.py develop for pywikibot
    Successfully installed PyJWT-1.7.1 certifi-2021.10.8 
charset-normalizer-2.0.11 idna-3.3 mwoauth-0.3.7 mwparserfromhell-0.6.3 
oauthlib-3.2.0 pywikibot-7.0.0.dev0 requests-2.27.1 requests-oauthlib-1.3.1 
six-1.16.0 urllib3-1.26.8
  
    $ python3 t.py -log -pt:0
    site._loginstatus=LoginStatus(-3); site.logged_in()=False
    Logging in ...
    site._loginstatus=LoginStatus(-2); site.logged_in()=True
    Editing a page ...
    Page [[Pywikibot test]] saved
    site._loginstatus=LoginStatus(-2); site.logged_in()=True
  
  
  
  name=t.py
    import pywikibot
    
    pywikibot.handle_args()
    
    site = pywikibot.Site('test', 'wikipedia')
    pywikibot.output(f'{site._loginstatus=}; {site.logged_in()=}')
    
    pywikibot.output('Logging in ...')
    site.login()
    pywikibot.output(f'{site._loginstatus=}; {site.logged_in()=}')
    
    pywikibot.output('Editing a page ...')
    page = pywikibot.Page(site, 'Pywikibot test')
    page.text = f'Test {site.server_time()}'
    page.save(summary=page.text)
    pywikibot.output(f'{site._loginstatus=}; {site.logged_in()=}')
  
  name=log
    2022-02-01 20:56:23             bot.py,  468 in     writelogheader: VERBOSE 
 === Pywikibot framework v7.0.0.dev0 -- Logging header ===
    2022-02-01 20:56:23             bot.py,  472 in     writelogheader: VERBOSE 
 COMMAND: ['t.py', '-log', '-pt:0']
    2022-02-01 20:56:23             bot.py,  475 in     writelogheader: VERBOSE 
 DATE: 2022-02-02 04:56:23.065527 UTC
    2022-02-01 20:56:23             bot.py,  479 in     writelogheader: VERBOSE 
 VERSION: [ssh] pywikibot-core (5fbfc49, g15894, 2022/02/01, 19:06:30, n/a)
    2022-02-01 20:56:23             bot.py,  486 in     writelogheader: VERBOSE 
 SYSTEM: posix.uname_result(sysname='Linux', nodename='DESKTOP-OVSD685', 
release='5.10.16.3-microsoft-standard-WSL2', version='#1 SMP Fri Apr 2 22:23:49 
UTC 2021', machine='x86_64')
    2022-02-01 20:56:23             bot.py,  489 in     writelogheader: VERBOSE 
 CONFIG FILE DIR: /home/jjmc89/.pywikibot
    2022-02-01 20:56:23             bot.py,  503 in     writelogheader: VERBOSE 
 PACKAGES:
    2022-02-01 20:56:23             bot.py,  513 in     writelogheader: VERBOSE 
   mwparserfromhell 
(/home/jjmc89/.pyenv/versions/pwb-39/lib/python3.9/site-packages/mwparserfromhell)
 = 0.6.3
    2022-02-01 20:56:23             bot.py,  513 in     writelogheader: VERBOSE 
   requests 
(/home/jjmc89/.pyenv/versions/pwb-39/lib/python3.9/site-packages/requests) = 
2.27.1
    [snip]
    2022-02-01 20:56:23               t.py,    6 in           <module>: INFO    
 site._loginstatus=LoginStatus(-3); site.logged_in()=False
    2022-02-01 20:56:23               t.py,    8 in           <module>: INFO    
 Logging in ...
    2022-02-01 20:56:23               t.py,   10 in           <module>: INFO    
 site._loginstatus=LoginStatus(-2); site.logged_in()=True
    2022-02-01 20:56:23               t.py,   12 in           <module>: INFO    
 Editing a page ...
    2022-02-01 20:56:24        __init__.py, 1241 in              _save: INFO    
 Page [[Pywikibot test]] saved
    2022-02-01 20:56:24               t.py,   16 in           <module>: INFO    
 site._loginstatus=LoginStatus(-2); site.logged_in()=True
    2022-02-01 20:56:24        __init__.py, 1333 in             _flush: VERBOSE 
 Dropped throttle(s).
    2022-02-01 20:56:24            http.py,   86 in              flush: VERBOSE 
 Closing network session.
    2022-02-01 20:56:24            http.py,   92 in              flush: VERBOSE 
 Network session closed.

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

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

To: JJMC89
Cc: H0bby, Shizhao, SuperHamster, Schlurcher, Count_Count, JJMC89, 
matej_suchanek, daniel, eprodromou, Tgr, Dvorapa, Xqt, Aklapper, Reedy, 
pywikibot-bugs-list, Multichill, Devnull, Jyoo1011, JohnsonLee01, SHEKH, 
Dijkstra, Khutuck, Zkhalido, WDoranWMF, EvanProdromou, Viztor, DannyS712, 
Wenyi, Amorymeltzer, Tbscho, MayS, Sethakill, Mdupont, dg711, Agabi10, 
Altostratus, Avicennasis, Pchelolo, mys_721tx, Bawolff, jayvdb, Masti, 
Alchimista, Legoktm
_______________________________________________
pywikibot-bugs mailing list -- pywikibot-bugs@lists.wikimedia.org
To unsubscribe send an email to pywikibot-bugs-le...@lists.wikimedia.org

Reply via email to