diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-07-22 21:02:14 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-07-22 21:02:14 +0300 |
commit | 413c79e3d89077964e6bab22a399750a3b9c20a6 (patch) | |
tree | 6cd4b9bd4fcf43b3d2ad853052762331db5c57d2 /Python/codecs.c | |
parent | 1d07a9119fd0c26acf4eec1e78317b82b12cf728 (diff) | |
parent | b2decdab33ce8b74051a8dcddfa409d7f9af8fb1 (diff) | |
download | cpython-413c79e3d89077964e6bab22a399750a3b9c20a6.tar.gz |
Issue #17944: test_zipfile now discoverable and uses subclassing to
generate tests for different compression types. Fixed a bug with skipping
some tests due to use of exhausted iterators.
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index fd67d1b9e1..899f0aa748 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -65,7 +65,7 @@ PyObject *normalizestring(const char *string) p = PyMem_Malloc(len + 1); if (p == NULL) - return NULL; + return PyErr_NoMemory(); for (i = 0; i < len; i++) { register char ch = string[i]; if (ch == ' ') @@ -761,7 +761,7 @@ PyCodec_SurrogatePassErrors(PyObject *exc) for (i = start; i < end; i++) { /* object is guaranteed to be "ready" */ Py_UCS4 ch = PyUnicode_READ_CHAR(object, i); - if (ch < 0xd800 || ch > 0xdfff) { + if (!Py_UNICODE_IS_SURROGATE(ch)) { /* Not a surrogate, fail with original exception */ PyErr_SetObject(PyExceptionInstance_Class(exc), exc); Py_DECREF(res); @@ -797,7 +797,7 @@ PyCodec_SurrogatePassErrors(PyObject *exc) (p[2] & 0xc0) == 0x80) { /* it's a three-byte code */ ch = ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f); - if (ch < 0xd800 || ch > 0xdfff) + if (!Py_UNICODE_IS_SURROGATE(ch)) /* it's not a surrogate - fail */ ch = 0; } @@ -1026,7 +1026,7 @@ static int _PyCodecRegistry_Init(void) if (interp->codec_error_registry) { for (i = 0; i < Py_ARRAY_LENGTH(methods); ++i) { - PyObject *func = PyCFunction_New(&methods[i].def, NULL); + PyObject *func = PyCFunction_NewEx(&methods[i].def, NULL, NULL); int res; if (!func) Py_FatalError("can't initialize codec error registry"); |