diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-05 21:43:57 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-05 21:43:57 (GMT) |
commit | de629d46f2a143e230398a820e9c090295f72ddb (patch) | |
tree | fc2cbab3df2c942d77f0f6ead9dc76e650ecd85d /Lib/tarfile.py | |
parent | aac786e5862ac032c903215d6632898af3002532 (diff) | |
download | cpython-de629d46f2a143e230398a820e9c090295f72ddb.zip cpython-de629d46f2a143e230398a820e9c090295f72ddb.tar.gz cpython-de629d46f2a143e230398a820e9c090295f72ddb.tar.bz2 |
Issue #8390: tarfile uses surrogateespace as the default error handler
(instead of replace in read mode or strict in write mode)
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index a888d69..81b13a6 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -978,7 +978,7 @@ class TarInfo(object): return info - def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="strict"): + def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"): """Return a tar header as a string of 512 byte blocks. """ info = self.get_info() @@ -1490,7 +1490,7 @@ class TarFile(object): def __init__(self, name=None, mode="r", fileobj=None, format=None, tarinfo=None, dereference=None, ignore_zeros=None, encoding=None, - errors=None, pax_headers=None, debug=None, errorlevel=None): + errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' @@ -1531,13 +1531,7 @@ class TarFile(object): self.ignore_zeros = ignore_zeros if encoding is not None: self.encoding = encoding - - if errors is not None: - self.errors = errors - elif mode == "r": - self.errors = "replace" - else: - self.errors = "strict" + self.errors = errors if pax_headers is not None and self.format == PAX_FORMAT: self.pax_headers = pax_headers |