diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-23 17:02:31 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-23 17:02:31 (GMT) |
commit | 75d8c5cea26912dd58f27689fbe9f7679e45aeb8 (patch) | |
tree | f314600d10b55375f26f58f145355458e4cc45b0 /Lib/distutils | |
parent | acd0fda1a46fa7d356c1e5de508dd33ce21e7a8f (diff) | |
download | cpython-75d8c5cea26912dd58f27689fbe9f7679e45aeb8.zip cpython-75d8c5cea26912dd58f27689fbe9f7679e45aeb8.tar.gz cpython-75d8c5cea26912dd58f27689fbe9f7679e45aeb8.tar.bz2 |
Issue #6011: sysconfig and distutils.sysconfig use the surrogateescape error
handler to parse the Makefile file. Avoid a UnicodeDecodeError if the source
code directory name contains a non-ASCII character and the locale encoding is
ASCII.
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/sysconfig.py | 2 | ||||
-rw-r--r-- | Lib/distutils/text_file.py | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index 8847e31..6b5daa5 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -271,7 +271,7 @@ def parse_makefile(fn, g=None): used instead of a new dictionary. """ from distutils.text_file import TextFile - fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) + fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1, errors="surrogateescape") if g is None: g = {} diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py index 97459fb..454725c 100644 --- a/Lib/distutils/text_file.py +++ b/Lib/distutils/text_file.py @@ -58,6 +58,8 @@ class TextFile: collapse_join [default: false] strip leading whitespace from lines that are joined to their predecessor; only matters if (join_lines and not lstrip_ws) + errors [default: 'strict'] + error handler used to decode the file content Note that since 'rstrip_ws' can strip the trailing newline, the semantics of 'readline()' must differ from those of the builtin file @@ -72,6 +74,7 @@ class TextFile: 'rstrip_ws': 1, 'join_lines': 0, 'collapse_join': 0, + 'errors': 'strict', } def __init__(self, filename=None, file=None, **options): @@ -111,7 +114,7 @@ class TextFile: """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', errors=self.errors) self.current_line = 0 def close(self): |