]> granicus.if.org Git - python/commitdiff
Fix a subtle bug in PyString_Repr().
authorGuido van Rossum <guido@python.org>
Tue, 3 Jul 2007 14:52:23 +0000 (14:52 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 3 Jul 2007 14:52:23 +0000 (14:52 +0000)
The smartquote code was deciding whether to use ' or "
by inspecting the *output* area...

Objects/stringobject.c

index dcecd6f60a87b113fe244022a73208daba5bc556..b5abdb696ee9f063a0ea2071ae1195891fe968e0 100644 (file)
@@ -854,8 +854,9 @@ PyString_Repr(PyObject *obj, int smartquotes)
                /* figure out which quote to use; single is preferred */
                quote = '\'';
                if (smartquotes) {
-                       Py_UNICODE *test;
-                       for (test = p; test < p+length; ++test) {
+                       char *test, *start;
+                       start = PyString_AS_STRING(op);
+                       for (test = start; test < start+length; ++test) {
                                if (*test == '"') {
                                        quote = '\''; /* switch back to single quote */
                                        goto decided;