diff --git a/debian/changelog b/debian/changelog index fda97f4..a116542 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ ubuntu-dev-tools (0.117) UNRELEASED; urgency=low * grab-merge: Show help when no arguments are provided. * pull-revu-source: Check for the availability of libwww-perl, and print a more helpful error. + * requestsync, grep-merges: Require a UTF-8 locale. (Closes: #613114, + LP: #553795) -- Stefano Rivera Sun, 13 Feb 2011 15:28:18 +0200 diff --git a/grep-merges b/grep-merges index 02d1317..aab5605 100755 --- a/grep-merges +++ b/grep-merges @@ -23,7 +23,10 @@ import sys import urllib2 import json +import ubuntutools.misc + def main(): + ubuntutools.misc.require_utf8() if len(sys.argv) > 1: match = sys.argv[1] else: diff --git a/requestsync b/requestsync index 7abe22e..cdd5ba2 100755 --- a/requestsync +++ b/requestsync @@ -35,6 +35,7 @@ from debian.changelog import Version from ubuntutools.config import UDTConfig, ubu_email from ubuntutools.distro_info import UbuntuDistroInfo from ubuntutools.lp import udtexceptions +import ubuntutools.misc from ubuntutools.requestsync.common import (edit_report, getDebianChangelog, raw_input_exit_on_ctrlc) @@ -89,6 +90,8 @@ def main(): parser.print_help() sys.exit(1) + ubuntutools.misc.require_utf8() + config = UDTConfig(options.no_conf) if not options.lpapi: options.lpapi = config.get_value('USE_LPAPI', default=False, diff --git a/ubuntutools/misc.py b/ubuntutools/misc.py index dd581d3..55c6551 100644 --- a/ubuntutools/misc.py +++ b/ubuntutools/misc.py @@ -22,9 +22,11 @@ # ################################################################## # Modules. +import locale import os import os.path from subprocess import Popen, PIPE +import sys from ubuntutools.lp.udtexceptions import PocketDoesNotExistError @@ -119,3 +121,10 @@ def split_release_pocket(release): pocket) return (release, pocket) + +def require_utf8(): + '''Can be called by programs that only function in UTF-8 locales''' + if locale.getpreferredencoding() != 'UTF-8': + print >> sys.stderr, ("This program only functions in a UTF-8 locale. " + "Aborting.") + sys.exit(1)