diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-22 13:37:56 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-22 13:37:56 (GMT) |
commit | 7df55dad3bd130992f5d978e8baf1119a7f2090b (patch) | |
tree | 977dc8c6e618ffdc1fb9a3ba67409b644217297b /Lib/codecs.py | |
parent | 54d2898ef85271f8fba369826469c16d59267a1a (diff) | |
download | cpython-7df55dad3bd130992f5d978e8baf1119a7f2090b.zip cpython-7df55dad3bd130992f5d978e8baf1119a7f2090b.tar.gz cpython-7df55dad3bd130992f5d978e8baf1119a7f2090b.tar.bz2 |
Issue #6268: More bugfixes about BOM, UTF-16 and UTF-32
* Fix seek() method of codecs.open(), don't write the BOM twice after seek(0)
* Fix reset() method of codecs, UTF-16, UTF-32 and StreamWriter classes
* test_codecs: use "w+" mode instead of "wt+". "t" mode is not supported by
Solaris or Windows, but does it really exist? I found it the in the issue.
Diffstat (limited to 'Lib/codecs.py')
-rw-r--r-- | Lib/codecs.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py index e903f2e..f4cd60a 100644 --- a/Lib/codecs.py +++ b/Lib/codecs.py @@ -370,6 +370,11 @@ class StreamWriter(Codec): """ pass + def seek(self, offset, whence=0): + self.stream.seek(offset, whence) + if whence == 0 and offset == 0: + self.reset() + def __getattr__(self, name, getattr=getattr): @@ -601,8 +606,8 @@ class StreamReader(Codec): Resets the codec buffers used for keeping state. """ - self.reset() self.stream.seek(offset, whence) + self.reset() def next(self): @@ -695,8 +700,10 @@ class StreamReaderWriter: self.writer.reset() def seek(self, offset, whence=0): - self.reader.seek(offset, whence) - self.writer.seek(offset, whence) + self.stream.seek(offset, whence) + self.reader.reset() + if whence == 0 and offset == 0: + self.writer.reset() def __getattr__(self, name, getattr=getattr): |