Platypush throws "method object is not iterable" error #278

Closed
opened 2023-08-18 15:16:12 +02:00 by AlphaDE · 3 comments

After having installed the rss part of platypush (pip install platypush[rss]) on a Ubuntu 20.04.6 LTS with Python 3.8.10, starting platypush shows the following error

2023-08-18 15:09:39,059|ERROR|platypush.plugins|'method' object is not iterable Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/__init__.py", line 34, in _execute_action result = f(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/variable/__init__.py", line 55, in set self.publish_entities(kwargs) File "/usr/local/lib/python3.8/dist-packages/platypush/entities/managers/__init__.py", line 109, in publish_entities self.transform_entities(entities or []) File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/variable/__init__.py", line 152, in transform_entities [ File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/variable/__init__.py", line 153, in <listcomp> Variable(id=var['name'], name=var['name'], value=var['value']) File "<string>", line 2, in __init__ File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/orm/instrumentation.py", line 551, in _new_state_if_none self._state_setter(instance, state) File "<string>", line 1, in set File "/usr/local/lib/python3.8/dist-packages/platypush/entities/_base.py", line 244, in __setattr__ matching_columns = [c for c in self.columns if c.expression.name == key] # type: ignore TypeError: 'method' object is not iterable INFO [alembic.runtime.migration] Context impl SQLiteImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL.

I found no way to work around this, installing platypush completely via git and pip install ., I end with

Traceback (most recent call last): File "/usr/local/bin/platypush", line 5, in <module> from platypush import main File "/usr/local/lib/python3.8/dist-packages/platypush/__init__.py", line 14, in <module> from .runner import main File "/usr/local/lib/python3.8/dist-packages/platypush/runner/__init__.py", line 3, in <module> from ._runner import ApplicationRunner File "/usr/local/lib/python3.8/dist-packages/platypush/runner/_runner.py", line 53 CommandStream(parsed_args.ctrl_sock) as stream, ^ SyntaxError: invalid syntax

when starting platypush.

Any help welcome.

After having installed the rss part of platypush (pip install platypush[rss]) on a Ubuntu 20.04.6 LTS with Python 3.8.10, starting platypush shows the following error `2023-08-18 15:09:39,059|ERROR|platypush.plugins|'method' object is not iterable Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/__init__.py", line 34, in _execute_action result = f(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/variable/__init__.py", line 55, in set self.publish_entities(kwargs) File "/usr/local/lib/python3.8/dist-packages/platypush/entities/managers/__init__.py", line 109, in publish_entities self.transform_entities(entities or []) File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/variable/__init__.py", line 152, in transform_entities [ File "/usr/local/lib/python3.8/dist-packages/platypush/plugins/variable/__init__.py", line 153, in <listcomp> Variable(id=var['name'], name=var['name'], value=var['value']) File "<string>", line 2, in __init__ File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/orm/instrumentation.py", line 551, in _new_state_if_none self._state_setter(instance, state) File "<string>", line 1, in set File "/usr/local/lib/python3.8/dist-packages/platypush/entities/_base.py", line 244, in __setattr__ matching_columns = [c for c in self.columns if c.expression.name == key] # type: ignore TypeError: 'method' object is not iterable INFO [alembic.runtime.migration] Context impl SQLiteImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. ` I found no way to work around this, installing platypush completely via git and pip install ., I end with `Traceback (most recent call last): File "/usr/local/bin/platypush", line 5, in <module> from platypush import main File "/usr/local/lib/python3.8/dist-packages/platypush/__init__.py", line 14, in <module> from .runner import main File "/usr/local/lib/python3.8/dist-packages/platypush/runner/__init__.py", line 3, in <module> from ._runner import ApplicationRunner File "/usr/local/lib/python3.8/dist-packages/platypush/runner/_runner.py", line 53 CommandStream(parsed_args.ctrl_sock) as stream, ^ SyntaxError: invalid syntax ` when starting platypush. Any help welcome.
Owner

Hi @AlphaDE,

Thanks for the report!

Both the cases seem to be regressions on Python 3.8 compatibility introduced by some of my recent changes.

The former is due to Entity.columns being a class property, and the combination of @classmethod + @property is only supported from Python 3.9.

The latter is due to a parenthesised multi-with statement - which, again, is only supported from Python 3.9.

A fix is on its way here and it should be merged on master soon - and a new pip release that will also include the fix is also on its way by the end of the weekend.

I try my best to keep Platypush back-compatible with as many versions of Python as possible, but as the list starts to stretch (the application is supposed to be compatible with any Python >= 3.7, and also 3.6 with some more limited support), and the list of supported distros also starts to extend, it's hard to keep track of all the moving parts.

I still want to try my best when it comes to back-compatibility because I know that there are many folks out there still running the application on Debian oldstable or old versions of CentOS, but in the future, if you aren't planning to upgrade your system, I may suggest you to consider the Docker option instead. The upcoming release will also come with improved Docker support, and by using a Docker image you're guaranteed to always use a more tested version - as Platypush is always tested against the latest stable version of Python (currently 3.11).

Hi @AlphaDE, Thanks for the report! Both the cases seem to be regressions on Python 3.8 compatibility introduced by some of my recent changes. The former is due to `Entity.columns` being a class property, and the combination of `@classmethod` + `@property` is only supported from Python 3.9. The latter is due to a parenthesised multi-with statement - which, again, is only supported from Python 3.9. A fix is on its way [here](https://git.platypush.tech/platypush/platypush/pulls/279) and it should be merged on master soon - and a new pip release that will also include the fix is also on its way by the end of the weekend. I try my best to keep Platypush back-compatible with as many versions of Python as possible, but as the list starts to stretch (the application is supposed to be compatible with any Python >= 3.7, and also 3.6 with some more limited support), and the list of supported distros also starts to extend, it's hard to keep track of all the moving parts. I still want to try my best when it comes to back-compatibility because I know that there are many folks out there still running the application on Debian oldstable or old versions of CentOS, but in the future, if you aren't planning to upgrade your system, I may suggest you to consider the Docker option instead. The upcoming release will also come with improved Docker support, and by using a Docker image you're guaranteed to always use a more tested version - as Platypush is always tested against the latest stable version of Python (currently 3.11).
blacklight added the
bug
in progress
labels 2023-08-18 16:38:33 +02:00
blacklight added reference 278/fix-variable-errors-on-python-3-8 2023-08-18 17:21:45 +02:00
Owner

Hi @AlphaDE,

The compatibility with Python 3.8 should be fixed in the latest commit on master. Feel free to reopen this issue if you still encounter issues.

Hi @AlphaDE, The compatibility with Python 3.8 should be fixed in the latest commit on master. Feel free to reopen this issue if you still encounter issues.
blacklight removed the
in progress
label 2023-08-18 22:48:54 +02:00
Author

Danke für den schnellen Fix, jetzt läuft es.

Danke für den schnellen Fix, jetzt läuft es.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: platypush/platypush#278
No description provided.