[Python-checkins] cpython (merge 3.2 -> default): Merge 3.2: Issue #9561: distutils now reads and writes egg-info files using

victor.stinner python-checkins at python.org
Mon Sep 5 23:50:27 CEST 2011


http://hg.python.org/cpython/rev/3c080bf75342
changeset:   72295:3c080bf75342
parent:      72292:33c671ac2e53
parent:      72294:fb4d2e6d393e
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Mon Sep 05 23:46:05 2011 +0200
summary:
  Merge 3.2: Issue #9561: distutils now reads and writes egg-info files using UTF-8

instead of the locale encoding.

files:
  Lib/distutils/command/install_egg_info.py |  5 ++---
  Lib/distutils/dist.py                     |  6 ++----
  Misc/NEWS                                 |  3 +++
  3 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/Lib/distutils/command/install_egg_info.py b/Lib/distutils/command/install_egg_info.py
--- a/Lib/distutils/command/install_egg_info.py
+++ b/Lib/distutils/command/install_egg_info.py
@@ -40,9 +40,8 @@
                          "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
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -1010,11 +1010,9 @@
     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.
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -271,6 +271,9 @@
 Library
 -------
 
+- Issue #9561: distutils now reads and writes egg-info files using UTF-8,
+  instead of the locale encoding.
+
 - Issue #8286: The distutils command sdist will print a warning message instead
   of crashing when an invalid path is given in the manifest template.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list