From d67340112a827598f43bc6d47f56f153ed16e946 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 14 May 2026 10:10:33 +0200 Subject: [PATCH] test script: test for file presence of replication script spec_from_loader does not check for validity of the file. --- scripts/osm2pgsql-test-style | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/osm2pgsql-test-style b/scripts/osm2pgsql-test-style index b173e2d0c..b5fd09b55 100755 --- a/scripts/osm2pgsql-test-style +++ b/scripts/osm2pgsql-test-style @@ -95,14 +95,18 @@ class ReplicationServerMock: # Replication module is optional -_repfl_spec = importlib.util.spec_from_loader( - 'osm2pgsql_replication', - SourceFileLoader('osm2pgsql_replication', - str(Path(__file__, '..', 'osm2pgsql-replication').resolve()))) +_replication_path = Path(__file__, '..', 'osm2pgsql-replication').resolve() + +if _replication_path.is_file(): + _repfl_spec = importlib.util.spec_from_loader( + 'osm2pgsql_replication', + SourceFileLoader('osm2pgsql_replication', str(_replication_path))) -if _repfl_spec: osm2pgsql_replication = importlib.util.module_from_spec(_repfl_spec) - _repfl_spec.loader.exec_module(osm2pgsql_replication) + try: + _repfl_spec.loader.exec_module(osm2pgsql_replication) + except Exception as e: + raise RuntimeError(f"osm2pgsql_replication script found but not readable.") from osmium.replication.server import OsmosisState else: