From 6d5eeed1b6ef0c04fd3f5f3e7eec4f1df546f35a Mon Sep 17 00:00:00 2001 From: vasily Date: Thu, 28 Feb 2013 19:27:39 +0400 Subject: [PATCH 1/3] Added .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..abefeee --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*pyc +fabfile.py +*swp From c41cf7b3728b378715312f1f264ad87444e09474 Mon Sep 17 00:00:00 2001 From: vasily Date: Thu, 28 Feb 2013 19:29:42 +0400 Subject: [PATCH 2/3] Added a fix for crash when incorrect LC_CTYPE is sent via ssh from Mac OS X --- command-not-found | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/command-not-found b/command-not-found index 010cdb3..1c73846 100755 --- a/command-not-found +++ b/command-not-found @@ -12,6 +12,7 @@ try: import gettext import locale import sys + import os from optparse import OptionParser from CommandNotFound.util import crash_guard @@ -26,7 +27,16 @@ def enable_i18n(): if sys.version < '3': kwargs["unicode"] = True cnf.install(**kwargs) - locale.setlocale(locale.LC_ALL, '') + + try: + locale.setlocale(locale.LC_ALL, '') + except locale.Error as exc: + # Fixing the case when remote system sends incorrect LC_CTYPE via SSH + if os.environ['LC_CTYPE'] == 'UTF-8': # Mac OS X + # Set the locale based on LANG environmental variable + locale.setlocale(locale.LC_ALL, os.environ['LANG'].split('.')) + else: + raise exc def fix_sys_argv(encoding=None): From 07e243c2acf85f1101115be5a4f94a1059d0b4ac Mon Sep 17 00:00:00 2001 From: vasily Date: Thu, 28 Feb 2013 19:57:20 +0400 Subject: [PATCH 3/3] Handle deriving locale from OS X SSH remote client in a safer way. --- command-not-found | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command-not-found b/command-not-found index 1c73846..0b90219 100755 --- a/command-not-found +++ b/command-not-found @@ -34,7 +34,7 @@ def enable_i18n(): # Fixing the case when remote system sends incorrect LC_CTYPE via SSH if os.environ['LC_CTYPE'] == 'UTF-8': # Mac OS X # Set the locale based on LANG environmental variable - locale.setlocale(locale.LC_ALL, os.environ['LANG'].split('.')) + locale.setlocale(locale.LC_ALL, os.environ.get('LANG', 'C')) else: raise exc