Checkpoint. Manipulated things so that string literals are always

unicode, and a few other compensating changes, e.g. str <- unicode,
chr <- unichr, and repr() of a unicode string no longer starts
with 'u'.  Lots of unit tests are broken, but some basic things
work, in particular distutils works so the extensions can be built,
and test_builtin.py works.
This commit is contained in:
Guido van Rossum 2007-04-27 23:53:51 +00:00
parent d4617f24ca
commit 572dbf8f13
28 changed files with 68 additions and 81 deletions

View file

@ -3187,7 +3187,7 @@ parsestr(const node *n, const char *encoding, int *bytesmode)
}
}
#ifdef Py_USING_UNICODE
if (unicode || Py_UnicodeFlag) {
if (!*bytesmode) {
return decode_unicode(s, len, rawmode, encoding);
}
#endif

View file

@ -2270,7 +2270,7 @@ static PyMethodDef builtin_methods[] = {
{"all", builtin_all, METH_O, all_doc},
{"any", builtin_any, METH_O, any_doc},
{"callable", builtin_callable, METH_O, callable_doc},
{"chr", builtin_chr, METH_VARARGS, chr_doc},
{"chr", builtin_unichr, METH_VARARGS, chr_doc},
{"cmp", builtin_cmp, METH_VARARGS, cmp_doc},
{"compile", (PyCFunction)builtin_compile, METH_VARARGS | METH_KEYWORDS, compile_doc},
{"delattr", builtin_delattr, METH_VARARGS, delattr_doc},
@ -2375,7 +2375,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("set", &PySet_Type);
SETBUILTIN("slice", &PySlice_Type);
SETBUILTIN("staticmethod", &PyStaticMethod_Type);
SETBUILTIN("str", &PyString_Type);
SETBUILTIN("str", &PyUnicode_Type);
SETBUILTIN("super", &PySuper_Type);
SETBUILTIN("tuple", &PyTuple_Type);
SETBUILTIN("type", &PyType_Type);

View file

@ -2633,7 +2633,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
PyObject *keyword = kws[2*i];
PyObject *value = kws[2*i + 1];
int j;
if (keyword == NULL || !PyString_Check(keyword)) {
if (keyword == NULL || !(PyString_Check(keyword) || PyUnicode_Check(keyword))) {
PyErr_Format(PyExc_TypeError,
"%.200s() keywords must be strings",
PyString_AsString(co->co_name));

View file

@ -1081,7 +1081,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'S': { /* string object */
PyObject **p = va_arg(*p_va, PyObject **);
if (PyString_Check(arg))
if (PyString_Check(arg) || PyUnicode_Check(arg))
*p = arg;
else
return converterr("string", arg, msgbuf, bufsize);
@ -1531,7 +1531,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
while (PyDict_Next(keywords, &pos, &key, &value)) {
int match = 0;
char *ks;
if (!PyString_Check(key)) {
if (!PyString_Check(key) && !PyUnicode_Check(key)) {
PyErr_SetString(PyExc_TypeError,
"keywords must be strings");
return cleanreturn(0, freelist);

View file

@ -154,7 +154,7 @@ _PyImport_Init(void)
}
}
if (Py_UnicodeFlag) {
{
/* Fix the pyc_magic so that byte compiled code created
using the all-Unicode method doesn't interfere with
code created in normal operation mode. */

View file

@ -76,7 +76,6 @@ int Py_InspectFlag; /* Needed to determine whether to exit at SystemError */
int Py_NoSiteFlag; /* Suppress 'import site' */
int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
int Py_FrozenFlag; /* Needed by getpath.c */
int Py_UnicodeFlag = 0; /* Needed by compile.c */
int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */
/* Reference to 'warnings' module, to avoid importing it