[Python-3000] setup.py fails in the py3k-struni branch

Guido van Rossum guido at python.org
Thu Jun 7 23:47:10 CEST 2007


On 6/7/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> > It's time to look at the original traceback (attached as "tb", after
> > fixing the formatting problems). it looks like any call to
> > encodings.normalize_encoding() causes this problem.
>
> One problem with normalize_encoding is that it might do
>
>   encoding = encoding.encode('latin-1')
>   return '_'.join(encoding.translate(_norm_encoding_map).split())
>
> Here, encoding is converted from a str (unicode) object
> into a bytes object. That is passed to translate, and then
> split, which in turn gives
>
> py> b"Hallo, World".split()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: split() takes at least 1 argument (0 given)
>
> So the problem is that bytes is not fully compatible with
> str or str8, here: it doesn't support the parameter-less
> split.

Which is intentional (sort of).

> In turn, normalize_encoding encodes as latin-1 because
> otherwise, translate won't work as expected.
>
> I think the right solution would be to just fix the
> translate table, replacing everything but [A-Za-z0-9]
> with a space.

I rewrote the algorithm using more basic operations. It's slower now
-- does that matter?  Here's what I checked in:

    chars = []
    punct = False
    for c in encoding:
        if c.isalnum() or c == '.':
            if punct and chars:
                chars.append('_')
            chars.append(c)
            punct = False
        else:
            punct = True
    return ''.join(chars)

> FWIW, for me the build error goes away when I unset
> LANG, so that the error occurs during build definitely
> *is* a locale issue.

I still can't reproduce this. Oh well. It should be gone.

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


More information about the Python-3000 mailing list