From 209954ee2fb652db70b84596b5accd35afbb87bb Mon Sep 17 00:00:00 2001 From: Lewis Gross <43077972+lewisgross1296@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:08:35 -0500 Subject: [PATCH] change back to prevent accidental infinite recursion Co-authored-by: Patrick Shriwise --- openmc/lib/tally.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openmc/lib/tally.py b/openmc/lib/tally.py index 90983d171..dc782539b 100644 --- a/openmc/lib/tally.py +++ b/openmc/lib/tally.py @@ -390,7 +390,12 @@ class Tally(_FortranObjectWithID): class _TallyMapping(Mapping): def __getitem__(self, key): - return Tally(index=self[key]) + index = c_int32() + try: + _dll.openmc_get_tally_index(key, index) + except (AllocationError, InvalidIDError) as e: + # __contains__ expects a KeyError to work correctly + raise KeyError(str(e)) def __iter__(self): for i in range(len(self)):