[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.125,2.126
Tim Peters
tim_one@users.sourceforge.net
Fri, 24 Aug 2001 20:02:30 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv18713/python/Objects
Modified Files:
stringobject.c
Log Message:
PyString_FromFormatV: Massage platform %p output to match what gcc does,
at least in the first two characters. %p is ill-defined, and people will
forever commit bad tests otherwise ("bad" in the sense that they fall
over (at least on Windows) for lack of a leading '0x'; 5 of the 7 tests
in test_repr.py failed on Windows for that reason this time around).
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.125
retrieving revision 2.126
diff -C2 -d -r2.125 -r2.126
*** stringobject.c 2001/08/24 18:32:06 2.125
--- stringobject.c 2001/08/25 03:02:28 2.126
***************
*** 270,273 ****
--- 270,281 ----
case 'p':
sprintf(s, "%p", va_arg(vargs, void*));
+ /* %p is ill-defined: ensure leading 0x. */
+ if (s[1] == 'X')
+ s[1] = 'x';
+ else if (s[1] != 'x') {
+ memmove(s+2, s, strlen(s)+1);
+ s[0] = '0';
+ s[1] = 'x';
+ }
s += strlen(s);
break;