brython-dev / brython

Brython (Browser Python) is an implementation of Python 3 running in the browser
BSD 3-Clause "New" or "Revised" License
6.39k stars 510 forks source link

3.9.4 breaks multiline python variable #1718

Closed xanthics closed 3 years ago

xanthics commented 3 years ago

While trying to automate some of my workflow (with selenium, grabbing the output of a dynamic page) I've encountered a project breaking change with 3.9.4. I've been using 3.9.0 (project here) and it's the token change between x.3 and x.4 that breaks my existing code.

Code like these two now generate SyntaxError: invalid syntax (invalid token )

    t <= COLGROUP(
        COL() +
        COL() +
        COL(Class='left_border') +
        COL(Class='left_dotted') +
        COL(Class='left_border') +
        COL(Class='left_dotted') +
        COL(Class='left_border') +
        COL(Class='left_dotted') +
        COL(Class='left_border') +
        COL(Class='left_dotted') +
        COL(Class='left_border') +
        COL(Class='left_dotted') +
        COL(Class='left_dotted') +
        COL(Class='left_border') +
        COL(Class='left_dotted') +
        COL(Class='left_dotted')
    )

characters = {
    "amber": {
        'ascension': {
            'element_1': 'agnidus_agate',
            'element_2': 'everflame_seed',
            'local': 'small_lamp_grass',
            'common': 'arrowhead'
        },
        'talent': {
            'talent': 'freedom',
            'common': 'arrowhead',
            'boss': 'dvalins_sigh'
        },
        'weapon': 'bow',
        'element': 'pyro'
    }
}

The only fix seems to be to make sure that each python variable is declared on a single line, however files like this one are 590 lines and would be too burdensome to work with as a single line

Is it intended that all python files be essentially minified going forward or was this an inadvertent change? This can be recreated by changing brython to 3.9.4 in either of my html files and loading them in chrome or firefox (I am doing this via Pycharm preview to start the local browser)


Ran in to this while trying to fix a JavaScript error: https://cdn.jsdelivr.net/npm/brython@3.9.3/brython.min.js line 7 > eval, line 1: Error: issue with Selenium, but I'm still troubleshooting that.

PierreQuentel commented 3 years ago

Sorry about that, it's a side effect of the rewriting of the Python tokenizer : the tabulation character was not supported...