Skip to content

Fix Callable exception in new versions of Python#72

Open
jordimas wants to merge 1 commit intomiracle2k:masterfrom
jordimas:master
Open

Fix Callable exception in new versions of Python#72
jordimas wants to merge 1 commit intomiracle2k:masterfrom
jordimas:master

Conversation

@jordimas
Copy link

@jordimas jordimas commented Oct 6, 2022

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'

@tosky
Copy link
Contributor

tosky commented Feb 25, 2023

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.

@albertvaka
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments