change back to prevent accidental infinite recursion

Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
This commit is contained in:
Lewis Gross 2022-08-16 13:08:35 -05:00 committed by GitHub
parent 15a863e645
commit 209954ee2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)):