From 20742bdde056cb4c32c86734a9e31b4cb5f00101 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 20 Jul 2012 01:55:25 +0000 Subject: [PATCH] Ignore failure of locale.getdefaultlocale. This was reported to be a problem with the en_NG (Nigerian English) locale by Kayode Adesina and Olisemeka Omo. http://seclists.org/nmap-dev/2012/q2/965 http://seclists.org/nmap-dev/2012/q3/270 The underlying Python bug is this: http://bugs.python.org/issue6895 --- CHANGELOG | 3 +++ zenmap/zenmapCore/I18N.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 20de9e108..1501eae68 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- +o [Zenmap] Fixed a crash when using the en_NG locale: "ValueError: + unknown locale: en_NG" [David Fifield] + o [NSE] Added http-get by Alex Weber. This script looks for a .git repository directory accesible over HTTP and extracts useful information from it. diff --git a/zenmap/zenmapCore/I18N.py b/zenmap/zenmapCore/I18N.py index 62b982fdf..f4391fa3a 100644 --- a/zenmap/zenmapCore/I18N.py +++ b/zenmap/zenmapCore/I18N.py @@ -106,9 +106,15 @@ def get_locales(): if val: locales = val.split(":") break - loc, enc = locale.getdefaultlocale() - if loc is not None: - locales.append(loc) + try: + loc, enc = locale.getdefaultlocale() + if loc is not None: + locales.append(loc) + except ValueError: + # locale.getdefaultlocale can fail with ValueError on certain locale + # names; it has been seen with at least en_NG. + # http://bugs.python.org/issue6895 + pass return locales def install_gettext(locale_dir):