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

Skip to content

Commit 3ccb09c

Browse files
committed
Fix for bug #222395: UTF-16 et al. don't handle .readline().
They now raise an NotImplementedError to hint to the truth ;-)
1 parent ffdd22f commit 3ccb09c

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

Lib/encodings/utf_16.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def read(self, size=-1):
5353
self.bom_read = 1
5454
return codecs.StreamReader.read(self, size)
5555

56+
def readline(self, size=None):
57+
raise NotImplementedError, '.readline() is not implemented for UTF-16'
58+
5659
### encodings module API
5760

5861
def getregentry():

Lib/encodings/utf_16_be.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class StreamWriter(Codec,codecs.StreamWriter):
2121
pass
2222

2323
class StreamReader(Codec,codecs.StreamReader):
24-
pass
24+
25+
def readline(self, size=None):
26+
raise NotImplementedError, '.readline() is not implemented for UTF-16-BE'
2527

2628
### encodings module API
2729

Lib/encodings/utf_16_le.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class StreamWriter(Codec,codecs.StreamWriter):
2121
pass
2222

2323
class StreamReader(Codec,codecs.StreamReader):
24-
pass
24+
25+
def readline(self, size=None):
26+
raise NotImplementedError, '.readline() is not implemented for UTF-16-LE'
2527

2628
### encodings module API
2729

0 commit comments

Comments
 (0)