Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 427dbff

Browse files
committed
Revert 55876. Use PyUnicode_AsEncodedString instead.
1 parent 543c09e commit 427dbff

2 files changed

Lines changed: 3 additions & 20 deletions

File tree

Python/codecs.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,23 +319,6 @@ PyObject *PyCodec_Encode(PyObject *object,
319319
PyObject *args = NULL, *result = NULL;
320320
PyObject *v;
321321

322-
/* XXX short-cut a few common file system
323-
encodings for now, as otherwise the import
324-
code can't load the codec registry. */
325-
if (strcmp(encoding, "utf-8") == 0 && PyUnicode_Check(object)) {
326-
return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(object),
327-
PyUnicode_GET_SIZE(object),
328-
errors);
329-
}
330-
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
331-
if (strcmp(encoding, "mbcs") == 0 && PyUnicode_Check(object)) {
332-
return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(object),
333-
PyUnicode_GET_SIZE(object),
334-
errors);
335-
}
336-
#endif
337-
338-
339322
encoder = PyCodec_Encoder(encoding);
340323
if (encoder == NULL)
341324
goto onError;

Python/import.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,10 +2305,10 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
23052305
if (!Py_FileSystemDefaultEncoding) {
23062306
item8 = PyUnicode_EncodeASCII(PyUnicode_AsUnicode(item),
23072307
PyUnicode_GetSize(item),
2308-
"strict");
2308+
NULL);
23092309
} else {
2310-
item8 = PyUnicode_AsEncodedObject(item,
2311-
Py_FileSystemDefaultEncoding, "strict");
2310+
item8 = PyUnicode_AsEncodedString(item,
2311+
Py_FileSystemDefaultEncoding, NULL);
23122312
}
23132313
if (!item8) {
23142314
PyErr_SetString(PyExc_ValueError, "Cannot encode path item");

0 commit comments

Comments
 (0)