mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Fix a subtle bug in PyString_Repr().
The smartquote code was deciding whether to use ' or " by inspecting the *output* area...
This commit is contained in:
parent
c1f779cb01
commit
a1cdfd9dc2
1 changed files with 3 additions and 2 deletions
|
@ -854,8 +854,9 @@ PyString_Repr(PyObject *obj, int smartquotes)
|
||||||
/* figure out which quote to use; single is preferred */
|
/* figure out which quote to use; single is preferred */
|
||||||
quote = '\'';
|
quote = '\'';
|
||||||
if (smartquotes) {
|
if (smartquotes) {
|
||||||
Py_UNICODE *test;
|
char *test, *start;
|
||||||
for (test = p; test < p+length; ++test) {
|
start = PyString_AS_STRING(op);
|
||||||
|
for (test = start; test < start+length; ++test) {
|
||||||
if (*test == '"') {
|
if (*test == '"') {
|
||||||
quote = '\''; /* switch back to single quote */
|
quote = '\''; /* switch back to single quote */
|
||||||
goto decided;
|
goto decided;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue