From: <pj...@us...> - 2009-04-04 04:11:19
|
Revision: 6157 http://jython.svn.sourceforge.net/jython/?rev=6157&view=rev Author: pjenvey Date: 2009-04-04 04:11:13 +0000 (Sat, 04 Apr 2009) Log Message: ----------- fix unicode format mappings to use unicode keys Modified Paths: -------------- trunk/jython/Lib/test/test_unicode_jy.py trunk/jython/src/org/python/core/PyString.java Modified: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py 2009-04-04 01:16:56 UTC (rev 6156) +++ trunk/jython/Lib/test/test_unicode_jy.py 2009-04-04 04:11:13 UTC (rev 6157) @@ -109,8 +109,21 @@ self.assertEquals('\xe2\x82\xac', encoded_euro) self.assertEquals(EURO_SIGN, encoded_euro.decode('utf-8')) + +class UnicodeFormatTestCase(unittest.TestCase): + + def test_unicode_mapping(self): + assertTrue = self.assertTrue + class EnsureUnicode(dict): + def __missing__(self, key): + assertTrue(isinstance(key, unicode)) + return key + u'%(foo)s' % EnsureUnicode() + + def test_main(): - test_support.run_unittest(UnicodeTestCase) + test_support.run_unittest(UnicodeTestCase, + UnicodeFormatTestCase) if __name__ == "__main__": Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2009-04-04 01:16:56 UTC (rev 6156) +++ trunk/jython/src/org/python/core/PyString.java 2009-04-04 04:11:13 UTC (rev 6157) @@ -2852,7 +2852,7 @@ parens++; } String tmp = format.substring(keyStart, index-1); - this.args = dict.__getitem__(new PyString(tmp)); + this.args = dict.__getitem__(needUnicode ? new PyUnicode(tmp) : new PyString(tmp)); } else { push(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |