Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 47496:2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Use faster PyUnicode_FromEncodedObject() for bytes/bytearray.decode().
Add new PyCodec_KnownEncoding() API.
Add new PyUnicode_AsDecodedUnicode() and PyUnicode_AsEncodedUnicode() APIs.
Add missing PyUnicode_AsDecodedObject() to unicodeobject.h
Fix punicode codec to also work on memoryviews.
| author | Marc-André Lemburg <mal@egenix.com> |
|---|---|
| date | Fri, 06 Jun 2008 12:18:17 +0000 |
| parents | b6b534b828b3 |
| children | 94f64f11fdd0 |
comparison
equal
deleted
inserted
replaced
| 47495:caa90cf6be9a | 47496:2284fa89ab08 |
|---|---|
| 259 initialized by other means. Also set the encoding of | 259 initialized by other means. Also set the encoding of |
| 260 stdin and stdout if these are terminals. */ | 260 stdin and stdout if these are terminals. */ |
| 261 | 261 |
| 262 codeset = nl_langinfo(CODESET); | 262 codeset = nl_langinfo(CODESET); |
| 263 if (codeset && *codeset) { | 263 if (codeset && *codeset) { |
| 264 PyObject *enc = PyCodec_Encoder(codeset); | 264 if (PyCodec_KnownEncoding(codeset)) |
| 265 if (enc) { | 265 codeset = strdup(codeset); |
| 266 codeset = strdup(codeset); | 266 else |
| 267 Py_DECREF(enc); | 267 codeset = NULL; |
| 268 } else { | |
| 269 codeset = NULL; | |
| 270 PyErr_Clear(); | |
| 271 } | |
| 272 } else | 268 } else |
| 273 codeset = NULL; | 269 codeset = NULL; |
| 274 | 270 |
| 275 if (codeset) { | 271 if (codeset) { |
| 276 if (!Py_FileSystemDefaultEncoding) | 272 if (!Py_FileSystemDefaultEncoding) |
