Index: Lib/distutils/sysconfig.py =================================================================== --- Lib/distutils/sysconfig.py (révision 84694) +++ Lib/distutils/sysconfig.py (copie de travail) @@ -271,8 +271,16 @@ used instead of a new dictionary. """ from distutils.text_file import TextFile - fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) + try: + import locale + encoding = locale.getpreferredencoding() + except ImportError: + # importing locale may fail during build + encoding = sys.getfilesystemencoding() + + fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1, encoding=encoding) + if g is None: g = {} done = {} Index: Lib/distutils/text_file.py =================================================================== --- Lib/distutils/text_file.py (révision 84694) +++ Lib/distutils/text_file.py (copie de travail) @@ -34,8 +34,7 @@ can include it in warning messages. If 'file' is not supplied, TextFile creates its own using 'io.open()'. - The options are all boolean, and affect the value returned by - 'readline()': + The options affect the value returned by 'readline()': strip_comments [default: true] strip from "#" to end-of-line, as well as any whitespace leading up to the "#" -- unless it is escaped by a backslash @@ -58,6 +57,8 @@ collapse_join [default: false] strip leading whitespace from lines that are joined to their predecessor; only matters if (join_lines and not lstrip_ws) + encoding [default: None] + file content encoding Note that since 'rstrip_ws' can strip the trailing newline, the semantics of 'readline()' must differ from those of the builtin file @@ -72,6 +73,7 @@ 'rstrip_ws': 1, 'join_lines': 0, 'collapse_join': 0, + 'encoding': None, } def __init__(self, filename=None, file=None, **options): @@ -111,7 +113,7 @@ """Open a new file named 'filename'. This overrides both the 'filename' and 'file' arguments to the constructor.""" self.filename = filename - self.file = io.open(self.filename, 'r') + self.file = io.open(self.filename, 'r', encoding=self.encoding) self.current_line = 0 def close(self):