Permalink
Browse files

If ProcessObject() gives us a bad status, check to see if we have a P…

…ython exception to raise

In the case of an OverflowError (see: issue #16), we want to raise *that*
exception instead of raising our own TypeError

Change-Id: I5b0cf5903b4cabe87df14137aa5d6c944ab3a270
  • Loading branch information...
1 parent 9e0c781 commit 215f62f9ba2451577c7b8926fe8e8dbba5a7f310 @rtyler committed Apr 11, 2010
Showing with 7 additions and 1 deletion.
  1. +7 −1 encoder.c
View
@@ -331,7 +331,13 @@ PyObject *_internal_encode(_YajlEncoder *self, PyObject *obj, yajl_gen_config ge
if ( (status == yajl_gen_in_error_state) ||
(status != yajl_gen_status_ok) ) {
- PyErr_SetObject(PyExc_TypeError, PyUnicode_FromString("Object is not JSON serializable"));
+ /*
+ * If we have an exception underneath the covers, let's raise that
+ * instead
+ */
+ if (!PyErr_Occurred()) {
+ PyErr_SetObject(PyExc_TypeError, PyUnicode_FromString("Object is not JSON serializable"));
+ }
Py_XDECREF(sauc.str);
return NULL;
}

0 comments on commit 215f62f

Please sign in to comment.