praneetnadella opened a new pull request, #41314:
URL: https://github.com/apache/beam/pull/41314
When `get_code_from_identifier` walks dotted prefixes in reverse and calls
`importlib.import_module(module_name)`, catching all `ImportError` and
`ModuleNotFoundError` exceptions swallows errors raised from inside the target
module itself (such as a missing third-party dependency or a broken `from ...
import ...` statement) and falls back to shorter parent package prefixes.
- Preserves the original `ModuleNotFoundError` or `ImportError` when an
unloaded target module fails during import instead of masking it as an
`AttributeError` or resolving a shadowed parent package attribute.
- Continues skipping `ModuleNotFoundError` when the probed `module_name` (or
an intermediate class prefix along `module_name`) is not a module.
<details>
<summary>Technical</summary>
- `sdks/python/apache_beam/internal/code_object_pickler.py`: In
`get_code_from_identifier`, narrow `except (ImportError, ModuleNotFoundError,
ValueError):` so `ModuleNotFoundError` only continues when `e.name ==
module_name` or `module_name.startswith(f'{e.name}.')`, and re-raises inner
`ModuleNotFoundError` and `ImportError` exceptions.
- `sdks/python/apache_beam/internal/code_object_pickler_test.py`: Add unit
tests verifying that inner `ModuleNotFoundError` and `ImportError` exceptions
from a submodule propagate while nested class paths inside a package still
resolve.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]