From 0de098468ff62728cc217677421659aa2adf0adb Mon Sep 17 00:00:00 2001 From: Pavel Yushchenko Date: Tue, 17 Sep 2013 20:41:22 +0400 Subject: [PATCH 1/3] fixes shlex unicode --- common/lib/capa/capa/inputtypes.py | 4 ++-- common/lib/capa/capa/tests/test_inputtypes.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index f6caee41c7..d55cbcb47d 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -309,13 +309,13 @@ class OptionInput(InputTypeBase): id==description for now. TODO: make it possible to specify different id and descriptions. """ # parse the set of possible options - lexer = shlex.shlex(options[1:-1]) + lexer = shlex.shlex(options[1:-1].encode('utf8')) lexer.quotes = "'" # Allow options to be separated by whitespace as well as commas lexer.whitespace = ", " # remove quotes - tokens = [x[1:-1] for x in list(lexer)] + tokens = [x[1:-1].decode('utf8') for x in list(lexer)] # make list of (option_id, option_description), with description=id return [(t, t) for t in tokens] diff --git a/common/lib/capa/capa/tests/test_inputtypes.py b/common/lib/capa/capa/tests/test_inputtypes.py index 626ed52d8c..0efd84f8cb 100644 --- a/common/lib/capa/capa/tests/test_inputtypes.py +++ b/common/lib/capa/capa/tests/test_inputtypes.py @@ -75,6 +75,10 @@ class OptionInputTest(unittest.TestCase): check("('a', 'b')", ['a', 'b']) check("('a b','b')", ['a b', 'b']) check("('My \"quoted\"place','b')", ['My \"quoted\"place', 'b']) + check(u"('б','в')", [u'б', u'в']) + check(u"('б', 'в')", [u'б', u'в']) + check(u"('б в','в')", [u'б в', u'в']) + check(u"('Мой \"кавыки\"место','в')", [u'Мой \"кавыки\"место', u'в']) class ChoiceGroupTest(unittest.TestCase): From d238e03f02a0c20f6605cf7ed80b77f130921de3 Mon Sep 17 00:00:00 2001 From: Pavel Yushchenko Date: Thu, 24 Oct 2013 16:14:15 +0400 Subject: [PATCH 2/3] remove cast to list --- common/lib/capa/capa/inputtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index d55cbcb47d..8a2ff099a1 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -315,7 +315,7 @@ class OptionInput(InputTypeBase): lexer.whitespace = ", " # remove quotes - tokens = [x[1:-1].decode('utf8') for x in list(lexer)] + tokens = [x[1:-1].decode('utf8') for x in lexer] # make list of (option_id, option_description), with description=id return [(t, t) for t in tokens] From 72aa5cbf57b06a946da73360ddd4056c08b572aa Mon Sep 17 00:00:00 2001 From: Pavel Yushchenko Date: Thu, 24 Oct 2013 16:55:16 +0400 Subject: [PATCH 3/3] added my name to AUTHORS --- AUTHORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 42c8351bb9..951570ee8b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -90,4 +90,5 @@ Nick Parlante Marko Seric Felipe Montoya Julia Hansbrough -Nicolas Chevalier \ No newline at end of file +Pavel Yushchenko +Nicolas Chevalier