From dcc88f964184b499d3ec6ed96b8aa438f2f98d55 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 20 May 2014 08:40:10 +0000 Subject: [PATCH] Catch exceptions in YAML menus * lib/mudpy/misc.py(Element.facets,Element.get): Early in login and account creation, elements can have None in place of a dict for their data. Under these circumstances, listing their keys throws AttributeError and deep-linking into specific keys throws TypeError. Catch these and treat them as empty. --- lib/mudpy/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mudpy/misc.py b/lib/mudpy/misc.py index 1f3909b..84d1a5e 100644 --- a/lib/mudpy/misc.py +++ b/lib/mudpy/misc.py @@ -104,7 +104,7 @@ class Element: if self.origin._format == "yaml": try: return self.origin.data[self.key].keys() - except KeyError: + except (AttributeError, KeyError): return [] else: if self.key in self.origin.data.sections(): @@ -143,7 +143,7 @@ class Element: if self.origin._format == "yaml": try: return self.origin.data[self.key][facet] - except KeyError: + except (KeyError, TypeError): pass if self.has_facet("inherit"): for ancestor in self.ancestry(): -- 2.11.0