From: Jeremy Stanley Date: Tue, 20 May 2014 08:40:10 +0000 (+0000) Subject: Catch exceptions in YAML menus X-Git-Tag: 0.0.1~240 X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=commitdiff_plain;h=dcc88f964184b499d3ec6ed96b8aa438f2f98d55;hp=24e9c787ca5751b65594737eb9ce1f42656de1be 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. --- 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():