cpython: 01d61096140a (original) (raw)
Mercurial > cpython
changeset 70205:01d61096140a
Issue #12112: packaging reads/writes metadata using UTF-8 [#12112]
Victor Stinner victor.stinner@haypocalc.com | |
---|---|
date | Thu, 19 May 2011 18:49:56 +0200 |
parents | fe740c1cee02 |
children | db9cb445c78f |
files | Lib/packaging/metadata.py Lib/packaging/tests/test_dist.py Lib/packaging/tests/test_metadata.py |
diffstat | 3 files changed, 9 insertions(+), 9 deletions(-)[+] [-] Lib/packaging/metadata.py 4 Lib/packaging/tests/test_dist.py 2 Lib/packaging/tests/test_metadata.py 12 |
line wrap: on
line diff
--- a/Lib/packaging/metadata.py +++ b/Lib/packaging/metadata.py @@ -307,7 +307,7 @@ class Metadata: def read(self, filepath): """Read the metadata values from a file path."""
with open(filepath, 'r', encoding='ascii') as fp:[](#l1.7)
with open(filepath, 'r', encoding='utf-8') as fp:[](#l1.8) self.read_file(fp)[](#l1.9)
def read_file(self, fileob): @@ -330,7 +330,7 @@ class Metadata: def write(self, filepath): """Write the metadata fields to filepath."""
with open(filepath, 'w') as fp:[](#l1.16)
with open(filepath, 'w', encoding='utf-8') as fp:[](#l1.17) self.write_file(fp)[](#l1.18)
def write_file(self, fileobject):
--- a/Lib/packaging/tests/test_dist.py +++ b/Lib/packaging/tests/test_dist.py @@ -78,7 +78,7 @@ class DistributionTestCase(support.Tempd # let's make sure the file can be written # with Unicode fields. they are encoded with # PKG_INFO_ENCODING
with open(my_file, 'w') as fp:[](#l2.7)
with open(my_file, 'w', encoding='utf-8') as fp:[](#l2.8) dist.metadata.write_file(fp)[](#l2.9)
# regular ascii is of course always usable
--- a/Lib/packaging/tests/test_metadata.py +++ b/Lib/packaging/tests/test_metadata.py @@ -17,7 +17,7 @@ class MetadataTestCase(LoggingCatcher, def test_instantiation(self): PKG_INFO = os.path.join(os.path.dirname(file), 'PKG-INFO')
with open(PKG_INFO, 'r') as f:[](#l3.7)
with open(PKG_INFO, 'r', encoding='utf-8') as f:[](#l3.8) contents = f.read()[](#l3.9) fp = StringIO(contents)[](#l3.10)
@@ -57,7 +57,7 @@ class MetadataTestCase(LoggingCatcher, def test_metadata_markers(self): # see if we can be platform-aware PKG_INFO = os.path.join(os.path.dirname(file), 'PKG-INFO')
with open(PKG_INFO, 'r') as f:[](#l3.16)
with open(PKG_INFO, 'r', encoding='utf-8') as f:[](#l3.17) content = f.read() % sys.platform[](#l3.18) metadata = Metadata(platform_dependent=True)[](#l3.19)
@@ -77,7 +77,7 @@ class MetadataTestCase(LoggingCatcher, def test_description(self): PKG_INFO = os.path.join(os.path.dirname(file), 'PKG-INFO')
with open(PKG_INFO, 'r') as f:[](#l3.25)
with open(PKG_INFO, 'r', encoding='utf-8') as f:[](#l3.26) content = f.read() % sys.platform[](#l3.27) metadata = Metadata()[](#l3.28) metadata.read_file(StringIO(content))[](#l3.29)
@@ -97,7 +97,7 @@ class MetadataTestCase(LoggingCatcher, def test_mapping_api(self): PKG_INFO = os.path.join(os.path.dirname(file), 'PKG-INFO')
with open(PKG_INFO, 'r') as f:[](#l3.34)
with open(PKG_INFO, 'r', encoding='utf-8') as f:[](#l3.35) content = f.read() % sys.platform[](#l3.36) metadata = Metadata(fileobj=StringIO(content))[](#l3.37) self.assertIn('Version', metadata.keys())[](#l3.38)
@@ -130,14 +130,14 @@ class MetadataTestCase(LoggingCatcher, PKG_INFO = os.path.join(os.path.dirname(file), 'SETUPTOOLS-PKG-INFO')
with open(PKG_INFO, 'r') as f:[](#l3.43)
with open(PKG_INFO, 'r', encoding='utf-8') as f:[](#l3.44) content = f.read()[](#l3.45) metadata.read_file(StringIO(content))[](#l3.46) self.assertEqual(metadata['Metadata-Version'], '1.0')[](#l3.47)
PKG_INFO = os.path.join(os.path.dirname(file), 'SETUPTOOLS-PKG-INFO2')
with open(PKG_INFO, 'r') as f:[](#l3.51)
with open(PKG_INFO, 'r', encoding='utf-8') as f:[](#l3.52) content = f.read()[](#l3.53) metadata.read_file(StringIO(content))[](#l3.54) self.assertEqual(metadata['Metadata-Version'], '1.1')[](#l3.55)