Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1bea6e

Browse files
author
Victor Stinner
committed
Issue #9561: distutils now reads and writes egg-info files using UTF-8
instead of the locale encoding.
1 parent a404b49 commit a1bea6e

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

Lib/distutils/command/install_egg_info.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ def run(self):
4040
"Creating "+self.install_dir)
4141
log.info("Writing %s", target)
4242
if not self.dry_run:
43-
f = open(target, 'w')
44-
self.distribution.metadata.write_pkg_file(f)
45-
f.close()
43+
with open(target, 'w', encoding='UTF-8') as f:
44+
self.distribution.metadata.write_pkg_file(f)
4645

4746
def get_outputs(self):
4847
return self.outputs

Lib/distutils/dist.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,11 +1010,9 @@ def __init__ (self):
10101010
def write_pkg_info(self, base_dir):
10111011
"""Write the PKG-INFO file into the release tree.
10121012
"""
1013-
pkg_info = open(os.path.join(base_dir, 'PKG-INFO'), 'w')
1014-
try:
1013+
with open(os.path.join(base_dir, 'PKG-INFO'), 'w',
1014+
encoding='UTF-8') as pkg_info:
10151015
self.write_pkg_file(pkg_info)
1016-
finally:
1017-
pkg_info.close()
10181016

10191017
def write_pkg_file(self, file):
10201018
"""Write the PKG-INFO format data to a file object.

Misc/NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Core and Builtins
2525
Library
2626
-------
2727

28+
- Issue #9561: distutils now reads and writes egg-info files using UTF-8,
29+
instead of the locale encoding.
30+
2831
- Issue #12888: Fix a bug in HTMLParser.unescape that prevented it to escape
2932
more than 128 entities. Patch by Peter Otten.
3033

@@ -72,7 +75,7 @@ Core and Builtins
7275

7376
Library
7477
-------
75-
78+
7679
- Issue #8286: The distutils command sdist will print a warning message instead
7780
of crashing when an invalid path is given in the manifest template.
7881

0 commit comments

Comments
 (0)