jpayne@69
|
1 """ Python 'undefined' Codec
|
jpayne@69
|
2
|
jpayne@69
|
3 This codec will always raise a ValueError exception when being
|
jpayne@69
|
4 used. It is intended for use by the site.py file to switch off
|
jpayne@69
|
5 automatic string to Unicode coercion.
|
jpayne@69
|
6
|
jpayne@69
|
7 Written by Marc-Andre Lemburg (mal@lemburg.com).
|
jpayne@69
|
8
|
jpayne@69
|
9 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
|
jpayne@69
|
10
|
jpayne@69
|
11 """
|
jpayne@69
|
12 import codecs
|
jpayne@69
|
13
|
jpayne@69
|
14 ### Codec APIs
|
jpayne@69
|
15
|
jpayne@69
|
16 class Codec(codecs.Codec):
|
jpayne@69
|
17
|
jpayne@69
|
18 def encode(self,input,errors='strict'):
|
jpayne@69
|
19 raise UnicodeError("undefined encoding")
|
jpayne@69
|
20
|
jpayne@69
|
21 def decode(self,input,errors='strict'):
|
jpayne@69
|
22 raise UnicodeError("undefined encoding")
|
jpayne@69
|
23
|
jpayne@69
|
24 class IncrementalEncoder(codecs.IncrementalEncoder):
|
jpayne@69
|
25 def encode(self, input, final=False):
|
jpayne@69
|
26 raise UnicodeError("undefined encoding")
|
jpayne@69
|
27
|
jpayne@69
|
28 class IncrementalDecoder(codecs.IncrementalDecoder):
|
jpayne@69
|
29 def decode(self, input, final=False):
|
jpayne@69
|
30 raise UnicodeError("undefined encoding")
|
jpayne@69
|
31
|
jpayne@69
|
32 class StreamWriter(Codec,codecs.StreamWriter):
|
jpayne@69
|
33 pass
|
jpayne@69
|
34
|
jpayne@69
|
35 class StreamReader(Codec,codecs.StreamReader):
|
jpayne@69
|
36 pass
|
jpayne@69
|
37
|
jpayne@69
|
38 ### encodings module API
|
jpayne@69
|
39
|
jpayne@69
|
40 def getregentry():
|
jpayne@69
|
41 return codecs.CodecInfo(
|
jpayne@69
|
42 name='undefined',
|
jpayne@69
|
43 encode=Codec().encode,
|
jpayne@69
|
44 decode=Codec().decode,
|
jpayne@69
|
45 incrementalencoder=IncrementalEncoder,
|
jpayne@69
|
46 incrementaldecoder=IncrementalDecoder,
|
jpayne@69
|
47 streamwriter=StreamWriter,
|
jpayne@69
|
48 streamreader=StreamReader,
|
jpayne@69
|
49 )
|