]> granicus.if.org Git - python/commitdiff
Issue #9561: distutils now reads and writes egg-info files using UTF-8
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 5 Sep 2011 21:44:56 +0000 (23:44 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 5 Sep 2011 21:44:56 +0000 (23:44 +0200)
instead of the locale encoding.

Lib/distutils/command/install_egg_info.py
Lib/distutils/dist.py
Misc/NEWS

index c8880310dfcf645fb5728dfb5ad90de79d24c17a..c2a7d649c0c58d90193a70cee0635bd6bb31f751 100644 (file)
@@ -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
index 02cd79ba2f61ec46c1520c707baff83aab236141..8ca5b6f4f1238884a63e41a324b26a3aba2707d7 100644 (file)
@@ -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.
index e0efb877876d07f7e244264f996ef8ad99f51902..401e0225d5f1fe7447235932f0df9fc51e0989f1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #9561: distutils now reads and writes egg-info files using UTF-8,
+  instead of the locale encoding.
+
 - Issue #12888: Fix a bug in HTMLParser.unescape that prevented it to escape
   more than 128 entities.  Patch by Peter Otten.
 
@@ -72,7 +75,7 @@ Core and Builtins
 
 Library
 -------
+
 - Issue #8286: The distutils command sdist will print a warning message instead
   of crashing when an invalid path is given in the manifest template.