android2po icon indicating copy to clipboard operation
android2po copied to clipboard

Fix Callable exception in new versions of Python

Open jordimas opened this issue 3 years ago • 2 comments

Fix the problem below in never versions of Python.

If you can please merge this and do a release. Thanks

File "/usr/local/bin/a2po", line 8, in sys.exit(run()) File "/usr/local/lib/python3.10/site-packages/android2po/program.py", line 234, in run sys.exit(main(sys.argv) or 0) File "/usr/local/lib/python3.10/site-packages/android2po/program.py", line 222, in main command_result = cmd.execute() File "/usr/local/lib/python3.10/site-packages/android2po/commands.py", line 422, in execute if self.generate_po(target_po, template_data, action, File "/usr/local/lib/python3.10/site-packages/android2po/commands.py", line 342, in generate_po return write_file(self, target_po_file, content=make_catalog, File "/usr/local/lib/python3.10/site-packages/android2po/commands.py", line 183, in write_file if isinstance(content, collections.Callable): AttributeError: module 'collections' has no attribute 'Callable'

jordimas avatar Oct 06 '22 10:10 jordimas

I'm just a user who hit the same issue, and I hope this fix will be getting noticed, but: wouldn't it be better to follow a try... except ImportError pattern, as in the import which comes next?

I was trying something like:

try:
    # the alias were removed in Python 3.10
    # https://github.com/python/cpython/issues/81505
    from collections.abc import Callable
except ImportError:  # pragma: no cover
    from collections import Callable

and then change the reference to collections.Callable to just Callable.

tosky avatar Feb 25 '23 22:02 tosky

Is there any chance we can get a new release including this fix? The current version is broken otherwise.

albertvaka avatar Jun 06 '23 21:06 albertvaka