[Python-checkins] r46663 - in python/trunk: Lib/bsddb/dbobj.py Lib/bsddb/test/test_basics.py Modules/_bsddb.c

Neal Norwitz nnorwitz at gmail.com
Mon Jun 5 07:10:09 CEST 2006


On 6/4/06, gregory.p.smith <python-checkins at python.org> wrote:
> Author: gregory.p.smith
> Date: Mon Jun  5 03:39:52 2006
> New Revision: 46663
>
> Modified: python/trunk/Modules/_bsddb.c
> ==============================================================================
> --- python/trunk/Modules/_bsddb.c       (original)
> +++ python/trunk/Modules/_bsddb.c       Mon Jun  5 03:39:52 2006
> @@ -4294,6 +4294,71 @@
>      RETURN_NONE();
>  }
>
> +#if (DBVER >= 40)

We know the version >= 40 here.

> +static PyObject*
> +DBEnv_log_stat(DBEnvObject* self, PyObject* args)
> +{
> +    int err;
> +    DB_LOG_STAT* statp = NULL;
> +    PyObject* d = NULL;
> +    u_int32_t flags = 0;
> +
> +    if (!PyArg_ParseTuple(args, "|i:log_stat", &flags))
> +        return NULL;

Shouldn't the format char be I (capital eye), since flags is unsigned?

> +    /* Turn the stat structure into a dictionary */
> +    d = PyDict_New();
> +    if (d == NULL) {
> +        if (statp)
> +            free(statp);
> +        return NULL;
> +    }

We check if statp is valid here before calling free.

> +#if (DBVER <= 40)
> +    MAKE_ENTRY(lg_max);
> +#endif

Wait, we already know the version is >= 40 than above.

> +#undef MAKE_ENTRY
> +    free(statp);
> +    return d;
> +} /* DBEnv_log_stat */
> +#endif /* DBVER >= 4.0 for log_stat method */

Why don't we check if statp is non-NULL here, we did above?

n


More information about the Python-checkins mailing list