On Sat, 16 Jun 2012 02:29:09 +0200
victor.stinner <python-check...@python.org> wrote:
> +    if (from_kind == to_kind) {
> +        if (!PyUnicode_IS_ASCII(from) && PyUnicode_IS_ASCII(to)) {
> +            /* Writing Latin-1 characters into an ASCII string requires to
> +               check that all written characters are pure ASCII */
> +#ifndef Py_DEBUG
> +            if (check_maxchar) {
> +                Py_UCS4 max_char;
> +                max_char = ucs1lib_find_max_char(from_data,
> +                                                 (char*)from_data + 
> how_many);
> +                if (max_char >= 128)
> +                    return -1;
> +            }
> +#else
> +            const Py_UCS4 to_maxchar = PyUnicode_MAX_CHAR_VALUE(to);
> +            Py_UCS4 ch;
> +            Py_ssize_t i;
> +            for (i=0; i < how_many; i++) {
> +                ch = PyUnicode_READ(from_kind, from_data, from_start + i);
> +                assert(ch <= to_maxchar);
> +            }
> +#endif

So you're returning -1 in release mode but you're crashing (assert())
in debug mode? Why that?

> +#ifndef Py_DEBUG
> +        if (!check_maxchar) {
[...]

This means the optimizations are not exercised in debug mode?
That sounds like a bad idea.

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to