Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9782 Modified Files: stringobject.c Log Message: The string formatting code has a test to switch to Unicode when %s sees a Unicode argument. Unfortunately this test was also executed for %r, because %s and %r share almost all of their code. This meant that, if u is a unicode object while repr(u) is an 8-bit string containing ASCII characters, '%r' % u is a *unicode* string containing only ASCII characters! Fixed by executing the test only for %s. Also fixed an error message -- %s argument has non-string str() doesn't make sense for %r, so the error message now differentiates between %s and %r. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.191 retrieving revision 2.192 diff -C2 -d -r2.191 -r2.192 *** stringobject.c 7 Oct 2002 18:26:16 -0000 2.191 --- stringobject.c 9 Oct 2002 19:07:53 -0000 2.192 *************** *** 3859,3863 **** break; case 's': - case 'r': #ifdef Py_USING_UNICODE if (PyUnicode_Check(v)) { --- 3859,3862 ---- *************** *** 3867,3870 **** --- 3866,3871 ---- } #endif + /* Fall through */ + case 'r': if (c == 's') temp = PyObject_Str(v); *************** *** 3875,3879 **** if (!PyString_Check(temp)) { PyErr_SetString(PyExc_TypeError, ! "%s argument has non-string str()"); Py_DECREF(temp); goto error; --- 3876,3882 ---- if (!PyString_Check(temp)) { PyErr_SetString(PyExc_TypeError, ! c == 's' ? ! "%s argument has non-string str()" : ! "%r argument has non-string repr()"); Py_DECREF(temp); goto error;
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4