Revert 55876. Use PyUnicode_AsEncodedString instead.

This commit is contained in:
Martin v. Löwis 2007-06-12 05:53:00 +00:00
parent 543c09e700
commit 427dbff8f0
2 changed files with 3 additions and 20 deletions

View File

@ -319,23 +319,6 @@ PyObject *PyCodec_Encode(PyObject *object,
PyObject *args = NULL, *result = NULL; PyObject *args = NULL, *result = NULL;
PyObject *v; PyObject *v;
/* XXX short-cut a few common file system
encodings for now, as otherwise the import
code can't load the codec registry. */
if (strcmp(encoding, "utf-8") == 0 && PyUnicode_Check(object)) {
return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(object),
PyUnicode_GET_SIZE(object),
errors);
}
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
if (strcmp(encoding, "mbcs") == 0 && PyUnicode_Check(object)) {
return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(object),
PyUnicode_GET_SIZE(object),
errors);
}
#endif
encoder = PyCodec_Encoder(encoding); encoder = PyCodec_Encoder(encoding);
if (encoder == NULL) if (encoder == NULL)
goto onError; goto onError;

View File

@ -2305,10 +2305,10 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
if (!Py_FileSystemDefaultEncoding) { if (!Py_FileSystemDefaultEncoding) {
item8 = PyUnicode_EncodeASCII(PyUnicode_AsUnicode(item), item8 = PyUnicode_EncodeASCII(PyUnicode_AsUnicode(item),
PyUnicode_GetSize(item), PyUnicode_GetSize(item),
"strict"); NULL);
} else { } else {
item8 = PyUnicode_AsEncodedObject(item, item8 = PyUnicode_AsEncodedString(item,
Py_FileSystemDefaultEncoding, "strict"); Py_FileSystemDefaultEncoding, NULL);
} }
if (!item8) { if (!item8) {
PyErr_SetString(PyExc_ValueError, "Cannot encode path item"); PyErr_SetString(PyExc_ValueError, "Cannot encode path item");