elif tok == STRING:
if lineno is None:
lineno = stup[0]
- buf.append(value[1:-1])
+ # Unwrap quotes in a safe manner
+ buf.append(eval(value, {'__builtins__':{}}, {}))
elif tok == OP and value == ',':
messages.append(''.join(buf))
del buf[:]
# history and logs, available at http://babel.edgewall.org/log/.
import doctest
+from StringIO import StringIO
import unittest
from babel.catalog import extract
+
+class ExtractPythonTestCase(unittest.TestCase):
+
+ def test_unicode_string_arg(self):
+ buf = StringIO("msg = _(u'Foo Bar')")
+ messages = list(extract.extract_python(buf, ('_',), {}))
+ self.assertEqual('Foo Bar', messages[0][2])
+
+
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(extract))
+ suite.addTest(unittest.makeSuite(ExtractPythonTestCase))
return suite
if __name__ == '__main__':