cpython: fe740c1cee02 (original) (raw)
Mercurial > cpython
changeset 70204:fe740c1cee02
Issue #12112: packaging reads and writes setup.cfg using UTF-8 [#12112]
Victor Stinner victor.stinner@haypocalc.com | |
---|---|
date | Thu, 19 May 2011 18:45:32 +0200 |
parents | 946baaeb1d10 |
children | 01d61096140a |
files | Lib/packaging/config.py Lib/packaging/create.py Lib/packaging/tests/support.py Lib/packaging/tests/test_config.py Lib/packaging/tests/test_create.py |
diffstat | 5 files changed, 11 insertions(+), 11 deletions(-)[+] [-] Lib/packaging/config.py 2 Lib/packaging/create.py 2 Lib/packaging/tests/support.py 4 Lib/packaging/tests/test_config.py 2 Lib/packaging/tests/test_create.py 12 |
line wrap: on
line diff
--- a/Lib/packaging/config.py +++ b/Lib/packaging/config.py @@ -282,7 +282,7 @@ class Config: for filename in filenames: logger.debug(" reading %s", filename)
parser.read(filename)[](#l1.7)
parser.read(filename, encoding='utf-8')[](#l1.8)
if os.path.split(filename)[-1] == 'setup.cfg': self._read_setup_cfg(parser, filename)
--- a/Lib/packaging/create.py +++ b/Lib/packaging/create.py @@ -276,7 +276,7 @@ class MainProgram: return shutil.move(_FILENAME, '%s.old' % _FILENAME)
with open(_FILENAME, 'w') as fp:[](#l2.7)
with open(_FILENAME, 'w', encoding='utf-8') as fp:[](#l2.8) fp.write('[metadata]\n')[](#l2.9) # simple string entries[](#l2.10) for name in ('name', 'version', 'summary', 'download_url'):[](#l2.11)
--- a/Lib/packaging/tests/support.py +++ b/Lib/packaging/tests/support.py @@ -138,7 +138,7 @@ class TempdirManager: d = tempfile.mkdtemp(dir=self._basetempdir) return d
path can be a string, a tuple or a list; if it's a tuple or list, @@ -146,7 +146,7 @@ class TempdirManager: """ if isinstance(path, (list, tuple)): path = os.path.join(*path)
with open(path, 'w') as f:[](#l3.16)
with open(path, 'w', encoding=encoding) as f:[](#l3.17) f.write(content)[](#l3.18)
--- a/Lib/packaging/tests/test_config.py +++ b/Lib/packaging/tests/test_config.py @@ -183,7 +183,7 @@ class ConfigTestCase(support.TempdirMana 'setup-hook': 'packaging.tests.test_config.hook'} if kwargs: opts.update(kwargs)
self.write_file('setup.cfg', SETUP_CFG % opts)[](#l4.7)
self.write_file('setup.cfg', SETUP_CFG % opts, encoding='utf-8')[](#l4.8)
def get_dist(self): dist = Distribution()
--- a/Lib/packaging/tests/test_create.py +++ b/Lib/packaging/tests/test_create.py @@ -91,7 +91,7 @@ class CreateTestCase(support.TempdirMana def test_convert_setup_py_to_cfg(self): self.write_file((self.wdir, 'setup.py'), dedent("""
# -*- coding: utf-8 -*-[](#l5.7)
# coding: utf-8[](#l5.8) from distutils.core import setup[](#l5.9)
long_description = '''My super Death-scription @@ -124,12 +124,12 @@ class CreateTestCase(support.TempdirMana }, scripts=['my_script', 'bin/run'], )
"""))[](#l5.16)
"""), encoding='utf-8')[](#l5.17) sys.stdin.write('y\n')[](#l5.18) sys.stdin.seek(0)[](#l5.19) main()[](#l5.20)
with open(os.path.join(self.wdir, 'setup.cfg')) as fp:[](#l5.22)
with open(os.path.join(self.wdir, 'setup.cfg'), encoding='utf-8') as fp:[](#l5.23) lines = set(line.rstrip() for line in fp)[](#l5.24)
# FIXME don't use sets @@ -171,7 +171,7 @@ class CreateTestCase(support.TempdirMana def test_convert_setup_py_to_cfg_with_description_in_readme(self): self.write_file((self.wdir, 'setup.py'), dedent("""
# -*- coding: utf-8 -*-[](#l5.31)
# coding: utf-8[](#l5.32) from distutils.core import setup[](#l5.33) with open('README.txt') as fp:[](#l5.34) long_description = fp.read()[](#l5.35)
@@ -191,7 +191,7 @@ class CreateTestCase(support.TempdirMana ('share/man', ['pyxfoil.1']), ], )
"""))[](#l5.40)
"""), encoding='utf-8')[](#l5.41) self.write_file((self.wdir, 'README.txt'),[](#l5.42) dedent('''[](#l5.43)
My super Death-scription
@@ -202,7 +202,7 @@ ho, baby
sys.stdin.seek(0)
# FIXME Out of memory error.
main()
with open(os.path.join(self.wdir, 'setup.cfg')) as fp:[](#l5.49)
with open(os.path.join(self.wdir, 'setup.cfg'), encoding='utf-8') as fp:[](#l5.50) lines = set(line.rstrip() for line in fp)[](#l5.51)