Mercurial > cpython-lru_cache-weakref
comparison Python/codecs.c @ 37252:52debbc3cc08 2.4
Backport of compile.c part of r41531 (neal.norwitz, 2005-11-24):
Fix a ref leak.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Mon, 27 Mar 2006 21:47:54 +0000 |
| parents | 201986d6d9d6 |
| children | 7fdc639bc5b4 |
comparison
equal
deleted
inserted
replaced
| 37250:c8f87f08fe0b | 37252:52debbc3cc08 |
|---|---|
| 34 if (search_function == NULL) { | 34 if (search_function == NULL) { |
| 35 PyErr_BadArgument(); | 35 PyErr_BadArgument(); |
| 36 goto onError; | 36 goto onError; |
| 37 } | 37 } |
| 38 if (!PyCallable_Check(search_function)) { | 38 if (!PyCallable_Check(search_function)) { |
| 39 PyErr_SetString(PyExc_TypeError, | 39 PyErr_SetString(PyExc_TypeError, "argument must be callable"); |
| 40 "argument must be callable"); | |
| 41 goto onError; | 40 goto onError; |
| 42 } | 41 } |
| 43 return PyList_Append(interp->codec_search_path, search_function); | 42 return PyList_Append(interp->codec_search_path, search_function); |
| 44 | 43 |
| 45 onError: | 44 onError: |
| 303 PyObject *PyCodec_Encode(PyObject *object, | 302 PyObject *PyCodec_Encode(PyObject *object, |
| 304 const char *encoding, | 303 const char *encoding, |
| 305 const char *errors) | 304 const char *errors) |
| 306 { | 305 { |
| 307 PyObject *encoder = NULL; | 306 PyObject *encoder = NULL; |
| 308 PyObject *args = NULL, *result; | 307 PyObject *args = NULL, *result = NULL; |
| 309 PyObject *v; | 308 PyObject *v; |
| 310 | 309 |
| 311 encoder = PyCodec_Encoder(encoding); | 310 encoder = PyCodec_Encoder(encoding); |
| 312 if (encoder == NULL) | 311 if (encoder == NULL) |
| 313 goto onError; | 312 goto onError; |
| 334 Py_DECREF(encoder); | 333 Py_DECREF(encoder); |
| 335 Py_DECREF(result); | 334 Py_DECREF(result); |
| 336 return v; | 335 return v; |
| 337 | 336 |
| 338 onError: | 337 onError: |
| 338 Py_XDECREF(result); | |
| 339 Py_XDECREF(args); | 339 Py_XDECREF(args); |
| 340 Py_XDECREF(encoder); | 340 Py_XDECREF(encoder); |
| 341 return NULL; | 341 return NULL; |
| 342 } | 342 } |
| 343 | 343 |
