Kaydet (Commit) 72f8213b authored tarafından Marc-André Lemburg's avatar Marc-André Lemburg

Fix for bug #438164: %-formatting using Unicode objects.

This patch also does away with an incompatibility between Jython
and CPython.
üst 0c4d8d05
...@@ -362,10 +362,7 @@ if sys.platform[:4] != 'java': ...@@ -362,10 +362,7 @@ if sys.platform[:4] != 'java':
verify(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def') verify(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def')
try: try:
if sys.platform[:4] != 'java': value = u"%(x)s, %()s" % {'x':u"abc", u'':"def"}
value = u"%(x)s, %()s" % {'x':u"abc", u''.encode('utf-8'):"def"}
else:
value = u"%(x)s, %()s" % {'x':u"abc", u'':"def"}
except KeyError: except KeyError:
print '*** formatting failed for "%s"' % "u'abc, def'" print '*** formatting failed for "%s"' % "u'abc, def'"
else: else:
......
...@@ -5300,6 +5300,7 @@ PyObject *PyUnicode_Format(PyObject *format, ...@@ -5300,6 +5300,7 @@ PyObject *PyUnicode_Format(PyObject *format,
"incomplete format key"); "incomplete format key");
goto onError; goto onError;
} }
#if 0
/* keys are converted to strings using UTF-8 and /* keys are converted to strings using UTF-8 and
then looked up since Python uses strings to hold then looked up since Python uses strings to hold
variables names etc. in its namespaces and we variables names etc. in its namespaces and we
...@@ -5307,6 +5308,9 @@ PyObject *PyUnicode_Format(PyObject *format, ...@@ -5307,6 +5308,9 @@ PyObject *PyUnicode_Format(PyObject *format,
key = PyUnicode_EncodeUTF8(keystart, key = PyUnicode_EncodeUTF8(keystart,
keylen, keylen,
NULL); NULL);
#else
key = PyUnicode_FromUnicode(keystart, keylen);
#endif
if (key == NULL) if (key == NULL)
goto onError; goto onError;
if (args_owned) { if (args_owned) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment