diff --git a/minigu/python/__init__.py b/minigu/python/__init__.py index 6b4047bbf..b23cf97c7 100644 --- a/minigu/python/__init__.py +++ b/minigu/python/__init__.py @@ -40,13 +40,8 @@ HAS_RUST_BINDINGS = True PyMiniGU = minigu_python.PyMiniGU # Try to import the error checking functions - try: - is_transaction_error = minigu_python.is_transaction_error - is_not_implemented_error = minigu_python.is_not_implemented_error - except AttributeError: - # Fallback if these functions are not available - is_transaction_error = None - is_not_implemented_error = None + is_transaction_error = getattr(minigu_python, 'is_transaction_error', None) + is_not_implemented_error = getattr(minigu_python, 'is_not_implemented_error', None) except ImportError as e: # Fallback if the Rust extension is not available HAS_RUST_BINDINGS = False diff --git a/minigu/python/minigu.py b/minigu/python/minigu.py index e2f1bacef..8749517f4 100644 --- a/minigu/python/minigu.py +++ b/minigu/python/minigu.py @@ -13,15 +13,8 @@ # Import from package __init__.py - this is the primary way to get the Rust bindings try: - from . import HAS_RUST_BINDINGS, PyMiniGU - # Try to import the error checking functions - try: - from . import is_transaction_error, is_not_implemented_error - except ImportError: - # Fallback if these functions are not available - is_transaction_error = None - is_not_implemented_error = None -except ImportError: + from . import HAS_RUST_BINDINGS, PyMiniGU, is_transaction_error, is_not_implemented_error +except (ImportError, ModuleNotFoundError): # Fallback when running directly or if package imports fail try: import minigu_python