initOS / odoo-analyse

Package to analyse and visualize odoo modules from the setup.py
GNU Lesser General Public License v3.0
25 stars 5 forks source link

syntax error with Python 3.5 #4

Closed olaf-wagner closed 3 years ago

olaf-wagner commented 3 years ago

Running the tool in our docker images for Odoo 12 with Python 3.5 packages installed results in this error:

odoo@36e1c0562d90:/$ odoo_analyse -h
Traceback (most recent call last):
  File "/usr/local/bin/odoo_analyse", line 7, in <module>
    from odoo_analyse.main import main
  File "/usr/local/lib/python3.5/dist-packages/odoo_analyse/__init__.py", line 4, in <module>
    from .model import Model
  File "/usr/local/lib/python3.5/dist-packages/odoo_analyse/model.py", line 6, in <module>
    from .utils import get_ast_source_segment
  File "/usr/local/lib/python3.5/dist-packages/odoo_analyse/utils.py", line 64
    hashes.append(f"{hashsum} {rel_path}")
                                        ^
SyntaxError: invalid syntax

The correction is easy: just add the missing concatenation operator in the utils module. It is also missing in line 85.

odoo@36e1c0562d90:/$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> hashes = []
>>> hashes.append("abc")
>>> f = "x"
>>> hashes.append(f"abc")
  File "<stdin>", line 1
    hashes.append(f"abc")
                       ^
SyntaxError: invalid syntax
>>> hashes.append(f + "abc")
>>>
fkantelberg commented 3 years ago

Hello,

the f-strings are new in python 3.6 which breaks the compatibility with python 3.5 sadly. You can see here for further details on them. The reason behind them are performance improvements and readability. We actually stated that it works under python 3.5. c5c50587ab1ff29f9660f1f4720768020f321e1a should fix this issue

olaf-wagner commented 3 years ago

On Wed, 02 Dec 2020 07:52:34 -0800 fkantelberg notifications@github.com wrote:

Hello,

the f-strings are new in python 3.6 which breaks the compatibility with python 3.5 sadly. You can see here for further details on them. The reason behind them are performance improvements and readability. We actually stated that it works under python 3.5. c5c50587ab1ff29f9660f1f4720768020f321e1a should fix this issue

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/initOS/odoo-analyse/issues/4#issuecomment-737318556

OK, thank you. I didn't even know that new feature; as you may guess, I'm not an active Python programmer anymore. Thanks for the fix.

Olaf -- Olaf Wagner -- elego Software Solutions GmbH -- http://www.elegosoft.com Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany Geschäftsführer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194