# HG changeset patch
# User Bob Ippolito <bob@redivi.com>
# Date 1357076254 28800
#      Tue Jan 01 13:37:34 2013 -0800
# Node ID ff714ca2bc6e7614faf4498aca2eae5ee5086a82
# Parent  f22c02e562846ff23d9b4654ea90d94775b6c905
bump to 3.0.2, fix Py_EnterRecusiveCall/Py_LeaveRecursiveCall balance from 3.0.1

diff --git a/CHANGES.txt b/CHANGES.txt
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,8 @@
+Version 3.0.2 released 2013-01-01
+
+* Missed a changeset to _speedups.c in the 3.0.1 branch cut, please
+  DO NOT install 3.0.1!
+
 Version 3.0.1 released 2013-01-01
 
 * Add accumulator optimization to encoder, equivalent to the usage of
diff --git a/conf.py b/conf.py
--- a/conf.py
+++ b/conf.py
@@ -44,7 +44,7 @@
 # The short X.Y version.
 version = '3.0'
 # The full version, including alpha/beta/rc tags.
-release = '3.0.1'
+release = '3.0.2'
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@
     DistutilsPlatformError
 
 IS_PYPY = hasattr(sys, 'pypy_translation_info')
-VERSION = '3.0.1'
+VERSION = '3.0.2'
 DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python"
 LONG_DESCRIPTION = open('README.rst', 'r').read()
 
diff --git a/simplejson/__init__.py b/simplejson/__init__.py
--- a/simplejson/__init__.py
+++ b/simplejson/__init__.py
@@ -99,7 +99,7 @@
     Expecting property name: line 1 column 2 (char 2)
 """
 from __future__ import absolute_import
-__version__ = '3.0.1'
+__version__ = '3.0.2'
 __all__ = [
     'dump', 'dumps', 'load', 'loads',
     'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c
--- a/simplejson/_speedups.c
+++ b/simplejson/_speedups.c
@@ -2312,7 +2312,6 @@
     /* Didn't find a string, object, array, or named constant. Look for a number. */
     if (fallthrough)
         rval = _match_number_unicode(s, pystr, idx, next_idx_ptr);
-    Py_LeaveRecursiveCall();
     return rval;
 }
 
@@ -2717,8 +2716,6 @@
 {
     /* Encode Python object obj to a JSON term, rval is a PyList */
     int rv = -1;
-    if (Py_EnterRecursiveCall(" while encoding a JSON document"))
-        return rv;
     do {
         if (obj == Py_None || obj == Py_True || obj == Py_False) {
             PyObject *cstr = _encoded_const(obj);
@@ -2748,17 +2745,26 @@
                 rv = _steal_accumulate(rval, encoded);
         }
         else if (s->namedtuple_as_object && _is_namedtuple(obj)) {
+            if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+                return rv;
             PyObject *newobj = PyObject_CallMethod(obj, "_asdict", NULL);
             if (newobj != NULL) {
                 rv = encoder_listencode_dict(s, rval, newobj, indent_level);
                 Py_DECREF(newobj);
             }
+            Py_LeaveRecursiveCall();
         }
         else if (PyList_Check(obj) || (s->tuple_as_array && PyTuple_Check(obj))) {
+            if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+                return rv;
             rv = encoder_listencode_list(s, rval, obj, indent_level);
+            Py_LeaveRecursiveCall();
         }
         else if (PyDict_Check(obj)) {
+            if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+                return rv;
             rv = encoder_listencode_dict(s, rval, obj, indent_level);
+            Py_LeaveRecursiveCall();
         }
         else if (s->use_decimal && PyObject_TypeCheck(obj, (PyTypeObject *)s->Decimal)) {
             PyObject *encoded = PyObject_Str(obj);
@@ -2785,12 +2791,15 @@
                     break;
                 }
             }
+            if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+                return rv;
             newobj = PyObject_CallFunctionObjArgs(s->defaultfn, obj, NULL);
             if (newobj == NULL) {
                 Py_XDECREF(ident);
                 break;
             }
             rv = encoder_listencode_obj(s, rval, newobj, indent_level);
+            Py_LeaveRecursiveCall();
             Py_DECREF(newobj);
             if (rv) {
                 Py_XDECREF(ident);
@@ -2805,7 +2814,6 @@
             }
         }
     } while (0);
-    Py_LeaveRecursiveCall();
     return rv;
 }