]> granicus.if.org Git - python/commitdiff
Fix for bug #438164: %-formatting using Unicode objects.
authorMarc-André Lemburg <mal@egenix.com>
Tue, 20 Nov 2001 15:18:49 +0000 (15:18 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Tue, 20 Nov 2001 15:18:49 +0000 (15:18 +0000)
This patch also does away with an incompatibility between Jython
and CPython.

Lib/test/test_unicode.py
Objects/unicodeobject.c

index b859fbb77e54ed42fe0b4627b19c8fd456714cc1..c701e44638b752c2161b5d260c9cd830f7094d4e 100644 (file)
@@ -362,10 +362,7 @@ if sys.platform[:4] != 'java':
 
 verify(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def')
 try:
-    if sys.platform[:4] != 'java':
-        value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"}
-    else:
-        value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä':"def"}
+    value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä':"def"}
 except KeyError:
     print '*** formatting failed for "%s"' % "u'abc, def'"
 else:
index 57ef62a7138fe9496022f62471f66a28836f9c99..142045514d2aba96cd787c249d664458cdaf01c9 100644 (file)
@@ -5300,6 +5300,7 @@ PyObject *PyUnicode_Format(PyObject *format,
                                    "incomplete format key");
                    goto onError;
                }
+#if 0
                /* keys are converted to strings using UTF-8 and
                   then looked up since Python uses strings to hold
                   variables names etc. in its namespaces and we
@@ -5307,6 +5308,9 @@ PyObject *PyUnicode_Format(PyObject *format,
                key = PyUnicode_EncodeUTF8(keystart,
                                           keylen,
                                           NULL);
+#else
+               key = PyUnicode_FromUnicode(keystart, keylen);
+#endif
                if (key == NULL)
                    goto onError;
                if (args_owned) {