[issue10829] PyUnicode_FromFormatV() bugs with "%" and "%%" format strings
Ray.Allen
report at bugs.python.org
Mon Feb 21 14:30:40 CET 2011
Ray.Allen <ysj.ray at gmail.com> added the comment:
Hi, haypo, Your patch seems cannot be applied cleanly on current py3k trunk. And after modified your patch, test_unicode.py runs into Segmentation fault. Is there something wrong or some changes which could influence this bug had been already made since the patch is worked out?
On the current trunk, I guess the bug could be fixed in a simpler way:
In step 1, before check '%%', check '%'(a string ends with '%') first. Then check '%%' and skip it.
The whole patch:
Index: Objects/unicodeobject.c
===================================================================
--- Objects/unicodeobject.c (revision 88453)
+++ Objects/unicodeobject.c (working copy)
@@ -750,8 +750,12 @@
* result in an array) */
for (f = format; *f; f++) {
if (*f == '%') {
- if (*(f+1)=='%')
+ if (*(f+1)=='\0')
+ continue;
+ if (*(f+1)=='%') {
+ f++;
continue;
+ }
if (*(f+1)=='S' || *(f+1)=='R' || *(f+1)=='A')
++callcount;
while (Py_ISDIGIT((unsigned)*f))
After applying this small patch and tests in your patch, test_unicode.py can passed.
----------
nosy: +ysj.ray
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10829>
_______________________________________
More information about the Python-bugs-list
mailing list