Page MenuHomePhabricator

pwb.py and setup.py should keep running with Python 2.7 and Python 3.4+
Open, LowestPublic

Description

pwb.py and setup.py should run with Python 2.7 and Python 3 to give a gracefull warning about version compatibiliy instead of breaking due to syntax error. Provide a syntax check for these two scripts.

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as Lowest priority.Aug 14 2020, 9:28 AM

Actually, Python 2.7 to 3 have some major syntax changes, for example, stdin is read through the input() function, and XML-RPC lib must be changed for backwards compatibility.

NullPointer raised the priority of this task from Lowest to Low.Aug 16 2020, 3:30 AM
NullPointer awarded a token.

Actually, Python 2.7 to 3 have some major syntax changes, for example, stdin is read through the input() function, and XML-RPC lib must be changed for backwards compatibility.

input() is not a different syntax and that library is not used by the framework. My idea is to have a simple CI check to validate that both of these two scripts run still with Python 2.7 or 3.4. Any different behaviour of Python implementations does not care because a version check is made in setup.py as well as in pwb.py very early.

Xqt renamed this task from pwb.py and setup.py should run with Python 2.7 and Python 3.4+ to pwb.py and setup.py should keep running with Python 2.7 and Python 3.4+.Aug 16 2020, 4:50 AM

Actually, Python 2.7 to 3 have some major syntax changes, for example, stdin is read through the input() function, and XML-RPC lib must be changed for backwards compatibility.

input() is not a different syntax and that library is not used by the framework. My idea is to have a simple CI check to validate that both of these two scripts run still with Python 2.7 or 3.4. Any different behaviour of Python implementations does not care because a version check is made in setup.py as well as in pwb.py very early.

I would like you to see what is it like if I use this in python 2.7.16.
Python3 input cannot accept scripts, but python 2.7.16 accepts scripts.

I am working on it and I will submit a PR on Github

I am working on it and I will submit a PR on Github

PR is not functional for pywikibot. Either use gerrit or if you doesn't have an account for it you may use the Gerrit Patch Uploader

I would like you to see what is it like if I use this in python 2.7.16.
Python3 input cannot accept scripts, but python 2.7.16 accepts scripts.

Cannot follow what you mean with this Statement. I also cannot find any error in that samle given by your file e.g.

>>> a = input()
s
Traceback (...

The behaviour is as expected because s is not defined previously. Try a instead because there is an assingment from input.

Anyway pwb.py does not reach any Input because the script is exited in line 186 when running with unsupported Python version. setup.py raises the RuntimeError in line 54 if a wrong Python version is used. The goal is to ensure these two scripts should not raise a syntaxError e.g. by using unsupported code parts like type hints or other code parts. Therefore a CI test can be implemented.

In the setup.py I found a comment stating that this version of Pywikibot is not intended to run on python 2.7, so closing task.

VERSIONS_REQUIRED_MESSAGE = """
Pywikibot is not available on:
{version}

This version of Pywikibot only supports Python 3.5+.
"""

Also, because I cannot clone from Gerrit I cannot commit to Gerrit, due to the internet connection.

Xqt removed NullPointer as the assignee of this task.
Xqt lowered the priority of this task from Low to Lowest.

In the setup.py I found a comment stating that this version of Pywikibot is not intended to run on python 2.7, so closing task.

Yes, Pywikibot is for Python 3.5 only. But setup.py and pwb.py should not fail due to a SyntaxError but raise that RuntimeError exception mentioned above instead which is more user friendly