[Python-3000-checkins] r57494 - python/branches/py3k/Objects/unicodeobject.c

Guido van Rossum guido at python.org
Sun Aug 26 17:13:35 CEST 2007


It was there because it's part of

if (result == 0) { ... }
else if (result == 1) { ... }
else { assert(result == 2); ... }

However the "..." in the last block contains declarations so the
assert was moved below the declarations, and, worse, one of the
declarations redefines 'result' (as a PyObject * initialized to NULL).
So as soon as result==2 you'd get the failing assert.

I think the assert serves a purpose. Perhaps a better solution would be to add

assert(0 <= result && result <= 2);

right after the place where the original result is computed.

(BTW the name MarkupIterator_next confused me for a while until I
remembered about stringlib. I think that after this has been
backported to 2.x, we should factor out the stringlib stuff so it's
just part of unicodeobject.c. Or it needs to use a better naming
convention.)

--Guido

On 8/25/07, neal.norwitz <python-3000-checkins at python.org> wrote:
> Author: neal.norwitz
> Date: Sun Aug 26 05:58:25 2007
> New Revision: 57494
>
> Modified:
>    python/branches/py3k/Objects/unicodeobject.c
> Log:
> Remove assert that seems out of place.  It triggers with test_string,
> but without it test_string passes.  I'm not sure why it was there.
>
>
> Modified: python/branches/py3k/Objects/unicodeobject.c
> ==============================================================================
> --- python/branches/py3k/Objects/unicodeobject.c        (original)
> +++ python/branches/py3k/Objects/unicodeobject.c        Sun Aug 26 05:58:25 2007
> @@ -9209,8 +9209,6 @@
>                  PyObject *conversion_str = NULL;
>                  PyObject *result = NULL;
>
> -                assert(result == 2);
> -
>                  is_markup_bool = PyBool_FromLong(is_markup);
>                  if (!is_markup_bool)
>                      goto error;
> _______________________________________________
> Python-3000-checkins mailing list
> Python-3000-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-3000-checkins
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000-checkins mailing list