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)