From a1cdfd9dc25648bf8db58c32f169baf8d5c73fc3 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 3 Jul 2007 14:52:23 +0000 Subject: [PATCH] Fix a subtle bug in PyString_Repr(). The smartquote code was deciding whether to use ' or " by inspecting the *output* area... --- Objects/stringobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/stringobject.c b/Objects/stringobject.c index dcecd6f60a8..b5abdb696ee 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -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;