bzexport: pass str to prompt_menu (bug 1183656); r?njn draft
authorGregory Szorc <gps@mozilla.com>
Mon, 25 Apr 2016 20:36:24 -0700
changeset 7902 2ce05d7ac0afc9e03183139f3a4882f2467cf6a5
parent 7901 836781a133a29cdd1f394faa3bdfebe3663b3233
push id777
push usergszorc@mozilla.com
push dateTue, 26 Apr 2016 03:36:28 +0000
reviewersnjn
bugs1183656
bzexport: pass str to prompt_menu (bug 1183656); r?njn prompt_menu expects a str message. search_results['search_string'] is a unicode type. When interpolated, Python 2 unhelpfully implicitly converts the literal str to a unicode. This later triggers implicit conversion back to a str assuming the ASCII encoding. MozReview-Commit-ID: CRvZxTmJQom
hgext/bzexport/__init__.py
--- a/hgext/bzexport/__init__.py
+++ b/hgext/bzexport/__init__.py
@@ -160,17 +160,17 @@ def choose_value(ui, desc, options, mess
     elif usemenu:
         return prompt_menu(ui, desc, list(options), message=message)
     return None
 
 
 def multi_user_prompt(ui, desc, search_results):
     return prompt_menu(ui, desc, search_results['names'],
                        readable_values=search_results['real_names'],
-                       message="Multiple bugzilla users matching \"%s\":\n\n" % search_results["search_string"],
+                       message="Multiple bugzilla users matching \"%s\":\n\n" % search_results["search_string"].encode('utf-8', 'replace'),
                        allow_none=True)
 
 
 # Returns [ { search_string: original, names: [ str ], real_names: [ str ] } ]
 def find_users(ui, api_server, user_cache_filename, auth, search_strings):
     c = bzauth.load_user_cache(ui, api_server, user_cache_filename)
     section = api_server