Skip to content

Fix exception handling in plugins/webreport when importing icu/PyICU #2050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martin-schwenke
Copy link

Exception handling is currently incomplete when both icu and PyICU are not installed.

First, fix the error in the most obvious way. Then remove duplicate exception handling.

If neither icu nor PyICU is installed then a failure like this
results:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gramps/gen/plug/_manager.py", line 270, i
n load_plugin
    _module = self.import_plugin(pdata)
  File "/usr/lib/python3/dist-packages/gramps/gen/plug/_manager.py", line 333, i
n import_plugin
    module = __import__(pdata.mod_name)
  File "/usr/lib/python3/dist-packages/gramps/plugins/webreport/narrativeweb.py"
, line 109, in <module>
    from gramps.plugins.webreport.basepage import BasePage
  File "/usr/lib/python3/dist-packages/gramps/plugins/webreport/basepage.py", li
ne 108, in <module>
    from gramps.plugins.webreport.common import (
    ...<10 lines>...
    )
  File "/usr/lib/python3/dist-packages/gramps/plugins/webreport/common.py", line
 682, in <module>
    AlphabeticIndex = localAlphabeticIndex  # type: ignore[misc, assignment]
                      ^^^^^^^^^^^^^^^^^^^^
NameError: name 'localAlphabeticIndex' is not defined

To avoid this, fall back to importing from local alphabeticindex.py.

Now it would be possible to remove the inner try: when importing
PyICU, since this change will also catch the exception there.
However, that should probably be done as a separate change, since the
current fix is minimal and clear.

Fixes #13407

Signed-off-by: Martin Schwenke <[email protected]>
@Nick-Hall Nick-Hall added the bug label Apr 21, 2025
@dsblank dsblank added this to the v6.1 milestone Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants