From 53aac29d05954bb62e25f14077acd6884d7ad9fc Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 18 Mar 2016 15:44:25 +0000 Subject: [PATCH] Avoid a zenmap crash if locale is not set properly --- zenmap/zenmapCore/NmapParser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zenmap/zenmapCore/NmapParser.py b/zenmap/zenmapCore/NmapParser.py index 9c9faa01a..35caf13d4 100644 --- a/zenmap/zenmapCore/NmapParser.py +++ b/zenmap/zenmapCore/NmapParser.py @@ -623,8 +623,12 @@ in epoch format!") return ports def get_formatted_date(self): - return time.strftime("%B %d, %Y - %H:%M", self.get_date()).decode( + try: + return time.strftime("%B %d, %Y - %H:%M", self.get_date()).decode( locale.getpreferredencoding()) + except LookupError: + # encoding or locale not found + return time.asctime(self.get_date()).decode('ascii') def get_scanner(self): return self.nmap['nmaprun'].get('scanner', '')