From 49009d966ad89673225986b4be085ebc8a9087ec Mon Sep 17 00:00:00 2001 From: Hans Ekkehard Plesser Date: Wed, 13 Mar 2024 11:05:27 +0100 Subject: [PATCH] Improved comment and changed exception type --- pynest/nest/lib/hl_api_types.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pynest/nest/lib/hl_api_types.py b/pynest/nest/lib/hl_api_types.py index d21b51f9e5..8a4ecf6a36 100644 --- a/pynest/nest/lib/hl_api_types.py +++ b/pynest/nest/lib/hl_api_types.py @@ -548,9 +548,11 @@ def __getattr__(self, attr): raise AttributeError("Cannot get attribute of empty NodeCollection") # IPython looks up this method when doing pretty printing - # Without special casing this, this would go through SLI which is *slow* + # As long as we do not provide special methods to support IPython prettyprinting, + # HTML-rendering, etc, we stop IPython from time-consuming checks by raising an + # exception here. The exception must *not* be AttributeError. if attr == "_ipython_canary_method_should_not_exist_": - raise KeyError(attr) + raise NotImplementedError("_ipython_canary_method_should_not_exist_") if attr == "spatial": metadata = sli_func("GetMetadata", self._datum)