summaryrefslogtreecommitdiffstats
path: root/Lib/encodings/oem.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2016-09-07 02:42:27 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2016-09-07 02:42:27 (GMT)
commitf5aba58480bb0dd45181f609487ac2ecfcc98673 (patch)
tree0d70301224f945e379c37058fa6b24b6ba8c78e5 /Lib/encodings/oem.py
parent22d0698d3b034f4f4314aa793da7225a5da640ba (diff)
downloadcpython-f5aba58480bb0dd45181f609487ac2ecfcc98673.zip
cpython-f5aba58480bb0dd45181f609487ac2ecfcc98673.tar.gz
cpython-f5aba58480bb0dd45181f609487ac2ecfcc98673.tar.bz2
Issue #27959: Adds oem encoding, alias ansi to mbcs, move aliasmbcs to codec lookup
Diffstat (limited to 'Lib/encodings/oem.py')
-rw-r--r--Lib/encodings/oem.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/Lib/encodings/oem.py b/Lib/encodings/oem.py
new file mode 100644
index 0000000..2c3426b
--- /dev/null
+++ b/Lib/encodings/oem.py
@@ -0,0 +1,41 @@
+""" Python 'oem' Codec for Windows
+
+"""
+# Import them explicitly to cause an ImportError
+# on non-Windows systems
+from codecs import oem_encode, oem_decode
+# for IncrementalDecoder, IncrementalEncoder, ...
+import codecs
+
+### Codec APIs
+
+encode = oem_encode
+
+def decode(input, errors='strict'):
+ return oem_decode(input, errors, True)
+
+class IncrementalEncoder(codecs.IncrementalEncoder):
+ def encode(self, input, final=False):
+ return oem_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
+ _buffer_decode = oem_decode
+
+class StreamWriter(codecs.StreamWriter):
+ encode = oem_encode
+
+class StreamReader(codecs.StreamReader):
+ decode = oem_decode
+
+### encodings module API
+
+def getregentry():
+ return codecs.CodecInfo(
+ name='oem',
+ encode=encode,
+ decode=decode,
+ incrementalencoder=IncrementalEncoder,
+ incrementaldecoder=IncrementalDecoder,
+ streamreader=StreamReader,
+ streamwriter=StreamWriter,
+ )