2000-06-07 06:04:05 -03:00
|
|
|
""" Python 'undefined' Codec
|
|
|
|
|
2024-03-17 01:58:42 -03:00
|
|
|
This codec will always raise a UnicodeError exception when being
|
2000-06-07 06:04:05 -03:00
|
|
|
used. It is intended for use by the site.py file to switch off
|
|
|
|
automatic string to Unicode coercion.
|
|
|
|
|
|
|
|
Written by Marc-Andre Lemburg (mal@lemburg.com).
|
|
|
|
|
|
|
|
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
|
|
|
|
|
|
|
|
"""
|
|
|
|
import codecs
|
|
|
|
|
|
|
|
### Codec APIs
|
|
|
|
|
|
|
|
class Codec(codecs.Codec):
|
|
|
|
|
|
|
|
def encode(self,input,errors='strict'):
|
2006-04-21 06:43:23 -03:00
|
|
|
raise UnicodeError("undefined encoding")
|
2000-06-07 06:04:05 -03:00
|
|
|
|
|
|
|
def decode(self,input,errors='strict'):
|
2006-04-21 06:43:23 -03:00
|
|
|
raise UnicodeError("undefined encoding")
|
|
|
|
|
|
|
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
|
|
|
def encode(self, input, final=False):
|
|
|
|
raise UnicodeError("undefined encoding")
|
|
|
|
|
|
|
|
class IncrementalDecoder(codecs.IncrementalDecoder):
|
|
|
|
def decode(self, input, final=False):
|
|
|
|
raise UnicodeError("undefined encoding")
|
2000-06-07 06:04:05 -03:00
|
|
|
|
|
|
|
class StreamWriter(Codec,codecs.StreamWriter):
|
|
|
|
pass
|
2002-08-08 17:19:19 -03:00
|
|
|
|
2000-06-07 06:04:05 -03:00
|
|
|
class StreamReader(Codec,codecs.StreamReader):
|
|
|
|
pass
|
|
|
|
|
|
|
|
### encodings module API
|
|
|
|
|
|
|
|
def getregentry():
|
2006-04-21 06:43:23 -03:00
|
|
|
return codecs.CodecInfo(
|
|
|
|
name='undefined',
|
|
|
|
encode=Codec().encode,
|
|
|
|
decode=Codec().decode,
|
|
|
|
incrementalencoder=IncrementalEncoder,
|
|
|
|
incrementaldecoder=IncrementalDecoder,
|
|
|
|
streamwriter=StreamWriter,
|
|
|
|
streamreader=StreamReader,
|
|
|
|
)
|