summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-05 21:44:56 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-05 21:44:56 (GMT)
commita1bea6e10c6177813aab34a0f05c3d531ec8fd66 (patch)
tree8dd844787a03faeb3c35492e8770f4eb4a2a6842 /Lib/distutils
parenta404b49321e877f3895c04da7edecae086b8d105 (diff)
downloadcpython-a1bea6e10c6177813aab34a0f05c3d531ec8fd66.zip
cpython-a1bea6e10c6177813aab34a0f05c3d531ec8fd66.tar.gz
cpython-a1bea6e10c6177813aab34a0f05c3d531ec8fd66.tar.bz2
Issue #9561: distutils now reads and writes egg-info files using UTF-8
instead of the locale encoding.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/command/install_egg_info.py5
-rw-r--r--Lib/distutils/dist.py6
2 files changed, 4 insertions, 7 deletions
diff --git a/Lib/distutils/command/install_egg_info.py b/Lib/distutils/command/install_egg_info.py
index c888031..c2a7d64 100644
--- a/Lib/distutils/command/install_egg_info.py
+++ b/Lib/distutils/command/install_egg_info.py
@@ -40,9 +40,8 @@ class install_egg_info(Command):
"Creating "+self.install_dir)
log.info("Writing %s", target)
if not self.dry_run:
- f = open(target, 'w')
- self.distribution.metadata.write_pkg_file(f)
- f.close()
+ with open(target, 'w', encoding='UTF-8') as f:
+ self.distribution.metadata.write_pkg_file(f)
def get_outputs(self):
return self.outputs
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index 02cd79b..8ca5b6f 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -1010,11 +1010,9 @@ class DistributionMetadata:
def write_pkg_info(self, base_dir):
"""Write the PKG-INFO file into the release tree.
"""
- pkg_info = open(os.path.join(base_dir, 'PKG-INFO'), 'w')
- try:
+ with open(os.path.join(base_dir, 'PKG-INFO'), 'w',
+ encoding='UTF-8') as pkg_info:
self.write_pkg_file(pkg_info)
- finally:
- pkg_info.close()
def write_pkg_file(self, file):
"""Write the PKG-INFO format data to a file object.