Skip to content

Conversation

martin-schwenke
Copy link

@martin-schwenke martin-schwenke commented Apr 21, 2025

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.

Fixes #13407.

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
@Nick-Hall Nick-Hall changed the title Fix exception handling in plugins/webreport when importing icu/PyICU Fix exception handling in narrated web report Jun 10, 2025
@Nick-Hall Nick-Hall changed the title Fix exception handling in narrated web report Fix icu/PyICU exception handling in narrated web report Jun 10, 2025
@Nick-Hall
Copy link
Member

@SNoiraud Have you seen this?

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