Index: moduleobject.c =================================================================== --- moduleobject.c (revision 57464) +++ moduleobject.c (working copy) @@ -66,17 +66,17 @@ d = ((PyModuleObject *)m)->md_dict; if (d == NULL || (nameobj = PyDict_GetItemString(d, "__name__")) == NULL || - !(PyString_Check(nameobj) || PyUnicode_Check(nameobj))) + !(PyUnicode_Check(nameobj))) { PyErr_SetString(PyExc_SystemError, "nameless module"); return NULL; } - if (PyUnicode_Check(nameobj)) { - nameobj = _PyUnicode_AsDefaultEncodedString(nameobj, NULL); + if (PyUnicode_Check(nameobj)) { + nameobj = PyUnicode_AsString(nameobj); if (nameobj == NULL) return NULL; } - return PyString_AsString(nameobj); + return nameobj; } char * @@ -91,12 +91,12 @@ d = ((PyModuleObject *)m)->md_dict; if (d == NULL || (fileobj = PyDict_GetItemString(d, "__file__")) == NULL || - !PyString_Check(fileobj)) + !PyUnicode_Check(fileobj)) { PyErr_SetString(PyExc_SystemError, "module filename missing"); return NULL; } - return PyString_AsString(fileobj); + return PyUnicode_AsString(fileobj); } void @@ -120,8 +120,8 @@ /* First, clear only names starting with a single underscore */ pos = 0; while (PyDict_Next(d, &pos, &key, &value)) { - if (value != Py_None && PyString_Check(key)) { - char *s = PyString_AsString(key); + if (value != Py_None && PyUnicode_Check(key)) { + char *s = PyUnicode_AsString(key); if (s[0] == '_' && s[1] != '_') { if (Py_VerboseFlag > 1) PySys_WriteStderr("# clear[1] %s\n", s); @@ -133,8 +133,8 @@ /* Next, clear all names except for __builtins__ */ pos = 0; while (PyDict_Next(d, &pos, &key, &value)) { - if (value != Py_None && PyString_Check(key)) { - char *s = PyString_AsString(key); + if (value != Py_None && PyUnicode_Check(key)) { + char *s = PyUnicode_AsString(key); if (s[0] != '_' || strcmp(s, "__builtins__") != 0) { if (Py_VerboseFlag > 1) PySys_WriteStderr("# clear[2] %s\n", s); Index: floatobject.c =================================================================== --- floatobject.c (revision 57464) +++ floatobject.c (working copy) @@ -74,11 +74,7 @@ Py_ssize_t len; PyObject *result = NULL; - if (PyString_Check(v)) { - s = PyString_AS_STRING(v); - len = PyString_GET_SIZE(v); - } - else if (PyUnicode_Check(v)) { + if (PyUnicode_Check(v)) { s_buffer = (char *)PyMem_MALLOC(PyUnicode_GET_SIZE(v)+1); if (s_buffer == NULL) return PyErr_NoMemory(); @@ -843,7 +839,7 @@ return float_subtype_new(type, args, kwds); /* Wimp out */ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x)) return NULL; - if (PyString_Check(x)) + if (PyUnicode_Check(x)) return PyFloat_FromString(x); return PyNumber_Float(x); } @@ -892,24 +888,25 @@ float_getformat(PyTypeObject *v, PyObject* arg) { char* s; + int len; float_format_type r; if (PyUnicode_Check(arg)) { - arg = _PyUnicode_AsDefaultEncodedString(arg, NULL); - if (arg == NULL) - return NULL; - } - if (!PyString_Check(arg)) { + s = PyUnicode_AsString(arg); + if (s == NULL) + return NULL; + len = PyUnicode_GET_SIZE(arg); + } else { PyErr_Format(PyExc_TypeError, - "__getformat__() argument must be string, not %.500s", - Py_Type(arg)->tp_name); - return NULL; - } - s = PyString_AS_STRING(arg); - if (strcmp(s, "double") == 0) { + "__getformat__() argument must be string, not %.500s", + Py_Type(arg)->tp_name); + return NULL; + } + + if (len==6 && strncmp(s, "double", 6) == 0) { r = double_format; } - else if (strcmp(s, "float") == 0) { + else if (len==5 && strncmp(s, "float", 5) == 0) { r = float_format; } else {