[Python-3000-checkins] r55978 - python/branches/py3k-struni/Objects/stringobject.c

guido.van.rossum python-3000-checkins at python.org
Fri Jun 15 02:00:14 CEST 2007


Author: guido.van.rossum
Date: Fri Jun 15 02:00:12 2007
New Revision: 55978

Modified:
   python/branches/py3k-struni/Objects/stringobject.c
Log:
Patch by Ron Adam to make repr(str8(...)) return something looking like
s'...' instead of '...', allowing it to be distinguished from unicode
strings.  This doesn't roundtrip -- for now, that's intentional, as the
goal is to rip these out rather than to make it a feature, and making
them stand out (breaking 8 more tests) helps us track them down so we
can rip them out.


Modified: python/branches/py3k-struni/Objects/stringobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/stringobject.c	(original)
+++ python/branches/py3k-struni/Objects/stringobject.c	Fri Jun 15 02:00:12 2007
@@ -835,7 +835,7 @@
 	static const char *hexdigits = "0123456789abcdef";
 	register PyStringObject* op = (PyStringObject*) obj;
 	Py_ssize_t length = PyString_GET_SIZE(op);
-	size_t newsize = 2 + 4 * op->ob_size;
+	size_t newsize = 3 + 4 * op->ob_size;
 	PyObject *v;
 	if (newsize > PY_SSIZE_T_MAX || newsize / 4 != op->ob_size) {
 		PyErr_SetString(PyExc_OverflowError,
@@ -867,7 +867,7 @@
 			;
 		}
 
-		*p++ = quote;
+		*p++ = 's', *p++ = quote;
 		for (i = 0; i < op->ob_size; i++) {
 			/* There's at least enough room for a hex escape
 			   and a closing quote. */


More information about the Python-3000-checkins mailing list