[Distutils] PEP 376 comments

Tarek Ziadé ziade.tarek at gmail.com
Thu Jun 11 14:11:03 CEST 2009

On Tue, Jun 9, 2009 at 12:18 AM, Sridhar
Ratnakumar<sridharr at activestate.com> wrote:
>> My best guess is that it doesn't use any encoding, it just
>> dumps the bytes in the string you specified in the PKG-INFO file (at
>> least for python2, I haven't checked what distutils does in python3).
> Correct; that is what I thought. Tarek said "The encoding used is utf-8
> since 2.6" .. for which I provided this counter-example (python-wifi-0.3.1).

In Python 2 >= 2.6 distutils uses dist.PKG_INFO_ENCODING (which is  'utf-8')

then, uses this encoding when it writes the PKG-INFO file.

That is:

        if isinstance(value, unicode):
            value = value.encode(PKG_INFO_ENCODING)
            value = str(value)
        file.write('%s: %s\n' % (name, value))

In Python 3 it just writes the fields like they are provided.

Tarek Ziadé | http://ziade.org

More information about the Distutils-SIG mailing list