summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-03 14:52:23 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-03 14:52:23 (GMT)
commita1cdfd9dc25648bf8db58c32f169baf8d5c73fc3 (patch)
treecb56d59d6f4df0a3f0d80bd7b1dba743e0fe5ce1 /Objects
parentc1f779cb015272412e4da2e5cb61b4e8cdcbf191 (diff)
downloadcpython-a1cdfd9dc25648bf8db58c32f169baf8d5c73fc3.zip
cpython-a1cdfd9dc25648bf8db58c32f169baf8d5c73fc3.tar.gz
cpython-a1cdfd9dc25648bf8db58c32f169baf8d5c73fc3.tar.bz2
Fix a subtle bug in PyString_Repr().
The smartquote code was deciding whether to use ' or " by inspecting the *output* area...
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index dcecd6f..b5abdb6 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;