jpayne@69: """ Python 'undefined' Codec jpayne@69: jpayne@69: This codec will always raise a ValueError exception when being jpayne@69: used. It is intended for use by the site.py file to switch off jpayne@69: automatic string to Unicode coercion. jpayne@69: jpayne@69: Written by Marc-Andre Lemburg (mal@lemburg.com). jpayne@69: jpayne@69: (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. jpayne@69: jpayne@69: """ jpayne@69: import codecs jpayne@69: jpayne@69: ### Codec APIs jpayne@69: jpayne@69: class Codec(codecs.Codec): jpayne@69: jpayne@69: def encode(self,input,errors='strict'): jpayne@69: raise UnicodeError("undefined encoding") jpayne@69: jpayne@69: def decode(self,input,errors='strict'): jpayne@69: raise UnicodeError("undefined encoding") jpayne@69: jpayne@69: class IncrementalEncoder(codecs.IncrementalEncoder): jpayne@69: def encode(self, input, final=False): jpayne@69: raise UnicodeError("undefined encoding") jpayne@69: jpayne@69: class IncrementalDecoder(codecs.IncrementalDecoder): jpayne@69: def decode(self, input, final=False): jpayne@69: raise UnicodeError("undefined encoding") jpayne@69: jpayne@69: class StreamWriter(Codec,codecs.StreamWriter): jpayne@69: pass jpayne@69: jpayne@69: class StreamReader(Codec,codecs.StreamReader): jpayne@69: pass jpayne@69: jpayne@69: ### encodings module API jpayne@69: jpayne@69: def getregentry(): jpayne@69: return codecs.CodecInfo( jpayne@69: name='undefined', jpayne@69: encode=Codec().encode, jpayne@69: decode=Codec().decode, jpayne@69: incrementalencoder=IncrementalEncoder, jpayne@69: incrementaldecoder=IncrementalDecoder, jpayne@69: streamwriter=StreamWriter, jpayne@69: streamreader=StreamReader, jpayne@69: )