From abb02e59946f9ea3076e96e3b03b51d1cebd46b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Walter=20D=C3=B6rwald?= <walter@livinglogic.de>
Date: Wed, 15 Mar 2006 11:35:15 +0000
Subject: Patch #1436130: codecs.lookup() now returns a CodecInfo object (a
 subclass of tuple) that provides incremental decoders and encoders (a way to
 use stateful codecs without the stream API). Functions
 codecs.getincrementaldecoder() and codecs.getincrementalencoder() have been
 added.

---
 Doc/lib/libcodecs.tex               | 168 +++++++++++++++++++++++++++++++--
 Include/codecs.h                    |  22 ++++-
 Lib/codecs.py                       | 183 +++++++++++++++++++++++++++++++++---
 Lib/encodings/__init__.py           |  33 ++++---
 Lib/encodings/ascii.py              |  19 +++-
 Lib/encodings/base64_codec.py       |  21 ++++-
 Lib/encodings/bz2_codec.py          |  21 ++++-
 Lib/encodings/charmap.py            |  31 ++++--
 Lib/encodings/cp037.py              |  24 ++++-
 Lib/encodings/cp1006.py             |  24 ++++-
 Lib/encodings/cp1026.py             |  24 ++++-
 Lib/encodings/cp1140.py             |  24 ++++-
 Lib/encodings/cp1250.py             |  24 ++++-
 Lib/encodings/cp1251.py             |  24 ++++-
 Lib/encodings/cp1252.py             |  24 ++++-
 Lib/encodings/cp1253.py             |  24 ++++-
 Lib/encodings/cp1254.py             |  24 ++++-
 Lib/encodings/cp1255.py             |  24 ++++-
 Lib/encodings/cp1256.py             |  24 ++++-
 Lib/encodings/cp1257.py             |  24 ++++-
 Lib/encodings/cp1258.py             |  24 ++++-
 Lib/encodings/cp424.py              |  24 ++++-
 Lib/encodings/cp437.py              |  23 ++++-
 Lib/encodings/cp500.py              |  24 ++++-
 Lib/encodings/cp737.py              |  23 ++++-
 Lib/encodings/cp775.py              |  24 +++--
 Lib/encodings/cp850.py              |  21 ++++-
 Lib/encodings/cp852.py              |  21 ++++-
 Lib/encodings/cp855.py              |  21 ++++-
 Lib/encodings/cp856.py              |  24 ++++-
 Lib/encodings/cp857.py              |  21 ++++-
 Lib/encodings/cp860.py              |  21 ++++-
 Lib/encodings/cp861.py              |  21 ++++-
 Lib/encodings/cp862.py              |  21 ++++-
 Lib/encodings/cp863.py              |  21 ++++-
 Lib/encodings/cp864.py              |  21 ++++-
 Lib/encodings/cp865.py              |  21 ++++-
 Lib/encodings/cp866.py              |  21 ++++-
 Lib/encodings/cp869.py              |  21 ++++-
 Lib/encodings/cp874.py              |  24 ++++-
 Lib/encodings/cp875.py              |  24 ++++-
 Lib/encodings/hex_codec.py          |  21 ++++-
 Lib/encodings/hp_roman8.py          |  21 ++++-
 Lib/encodings/idna.py               |  19 +++-
 Lib/encodings/iso8859_1.py          |  24 ++++-
 Lib/encodings/iso8859_10.py         |  24 ++++-
 Lib/encodings/iso8859_11.py         |  24 ++++-
 Lib/encodings/iso8859_13.py         |  24 ++++-
 Lib/encodings/iso8859_14.py         |  24 ++++-
 Lib/encodings/iso8859_15.py         |  24 ++++-
 Lib/encodings/iso8859_16.py         |  24 ++++-
 Lib/encodings/iso8859_2.py          |  24 ++++-
 Lib/encodings/iso8859_3.py          |  24 ++++-
 Lib/encodings/iso8859_4.py          |  24 ++++-
 Lib/encodings/iso8859_5.py          |  24 ++++-
 Lib/encodings/iso8859_6.py          |  24 ++++-
 Lib/encodings/iso8859_7.py          |  24 ++++-
 Lib/encodings/iso8859_8.py          |  24 ++++-
 Lib/encodings/iso8859_9.py          |  24 ++++-
 Lib/encodings/koi8_r.py             |  24 ++++-
 Lib/encodings/koi8_u.py             |  24 ++++-
 Lib/encodings/latin_1.py            |  18 +++-
 Lib/encodings/mac_arabic.py         |  21 ++++-
 Lib/encodings/mac_centeuro.py       |  24 ++++-
 Lib/encodings/mac_croatian.py       |  24 ++++-
 Lib/encodings/mac_cyrillic.py       |  24 ++++-
 Lib/encodings/mac_farsi.py          |  24 ++++-
 Lib/encodings/mac_greek.py          |  24 ++++-
 Lib/encodings/mac_iceland.py        |  24 ++++-
 Lib/encodings/mac_latin2.py         |  21 ++++-
 Lib/encodings/mac_roman.py          |  24 ++++-
 Lib/encodings/mac_romanian.py       |  24 ++++-
 Lib/encodings/mac_turkish.py        |  24 ++++-
 Lib/encodings/mbcs.py               |  18 +++-
 Lib/encodings/palmos.py             |  18 +++-
 Lib/encodings/ptcp154.py            |  21 ++++-
 Lib/encodings/punycode.py           |  24 ++++-
 Lib/encodings/quopri_codec.py       |  18 +++-
 Lib/encodings/raw_unicode_escape.py |  19 +++-
 Lib/encodings/rot_13.py             |  21 ++++-
 Lib/encodings/string_escape.py      |  19 +++-
 Lib/encodings/tis_620.py            |  24 ++++-
 Lib/encodings/undefined.py          |  23 ++++-
 Lib/encodings/unicode_escape.py     |  19 +++-
 Lib/encodings/unicode_internal.py   |  19 +++-
 Lib/encodings/utf_16.py             |  52 +++++++++-
 Lib/encodings/utf_16_be.py          |  18 +++-
 Lib/encodings/utf_16_le.py          |  19 +++-
 Lib/encodings/utf_7.py              |  19 +++-
 Lib/encodings/utf_8.py              |  18 +++-
 Lib/encodings/utf_8_sig.py          |  47 ++++++++-
 Lib/encodings/uu_codec.py           |  20 +++-
 Lib/encodings/zlib_codec.py         |  21 ++++-
 Lib/test/test_codecs.py             |  57 +++++++++++
 Misc/NEWS                           |   6 ++
 Python/codecs.c                     |  50 ++++++++++
 Tools/unicode/Makefile              |   4 +-
 Tools/unicode/gencodec.py           |  61 ++++++++----
 98 files changed, 2212 insertions(+), 420 deletions(-)

diff --git a/Doc/lib/libcodecs.tex b/Doc/lib/libcodecs.tex
index 9e92217..1806ef0 100644
--- a/Doc/lib/libcodecs.tex
+++ b/Doc/lib/libcodecs.tex
@@ -24,8 +24,19 @@ It defines the following functions:
 \begin{funcdesc}{register}{search_function}
 Register a codec search function. Search functions are expected to
 take one argument, the encoding name in all lower case letters, and
-return a tuple of functions \code{(\var{encoder}, \var{decoder}, \var{stream_reader},
-\var{stream_writer})} taking the following arguments:
+return a \class{CodecInfo} object having the following attributes:
+
+\begin{itemize}
+  \item \code{name} The name of the encoding;
+  \item \code{encoder} The stateless encoding function;
+  \item \code{decoder} The stateless decoding function;
+  \item \code{incrementalencoder} An incremental encoder class or factory function;
+  \item \code{incrementaldecoder} An incremental decoder class or factory function;
+  \item \code{streamwriter} A stream writer class or factory function;
+  \item \code{streamreader} A stream reader class or factory function.
+\end{itemize}
+
+The various functions or classes take the following arguments:
 
   \var{encoder} and \var{decoder}: These must be functions or methods
   which have the same interface as the
@@ -33,7 +44,17 @@ return a tuple of functions \code{(\var{encoder}, \var{decoder}, \var{stream_rea
   Codec Interface). The functions/methods are expected to work in a
   stateless mode.
 
-  \var{stream_reader} and \var{stream_writer}: These have to be
+  \var{incrementalencoder} and \var{incrementalencoder}: These have to be
+  factory functions providing the following interface:
+
+        \code{factory(\var{errors}='strict')}
+
+  The factory functions must return objects providing the interfaces
+  defined by the base classes \class{IncrementalEncoder} and
+  \class{IncrementalEncoder}, respectively. Incremental codecs can maintain
+  state.
+
+  \var{streamreader} and \var{streamwriter}: These have to be
   factory functions providing the following interface:
 
         \code{factory(\var{stream}, \var{errors}='strict')}
@@ -58,13 +79,13 @@ return \code{None}.
 \end{funcdesc}
 
 \begin{funcdesc}{lookup}{encoding}
-Looks up a codec tuple in the Python codec registry and returns the
-function tuple as defined above.
+Looks up the codec info in the Python codec registry and returns a
+\class{CodecInfo} object as defined above.
 
 Encodings are first looked up in the registry's cache. If not found,
-the list of registered search functions is scanned. If no codecs tuple
-is found, a \exception{LookupError} is raised. Otherwise, the codecs
-tuple is stored in the cache and returned to the caller.
+the list of registered search functions is scanned. If no \class{CodecInfo}
+object is found, a \exception{LookupError} is raised. Otherwise, the
+\class{CodecInfo} object is stored in the cache and returned to the caller.
 \end{funcdesc}
 
 To simplify access to the various codecs, the module provides these
@@ -85,6 +106,22 @@ function.
 Raises a \exception{LookupError} in case the encoding cannot be found.
 \end{funcdesc}
 
+\begin{funcdesc}{getincrementalencoder}{encoding}
+Lookup up the codec for the given encoding and return its incremental encoder
+class or factory function.
+
+Raises a \exception{LookupError} in case the encoding cannot be found or the
+codec doesn't support an incremental encoder.
+\end{funcdesc}
+
+\begin{funcdesc}{getincrementaldecoder}{encoding}
+Lookup up the codec for the given encoding and return its incremental decoder
+class or factory function.
+
+Raises a \exception{LookupError} in case the encoding cannot be found or the
+codec doesn't support an incremental decoder.
+\end{funcdesc}
+
 \begin{funcdesc}{getreader}{encoding}
 Lookup up the codec for the given encoding and return its StreamReader
 class or factory function.
@@ -188,6 +225,18 @@ If \var{output} is not given, it defaults to \var{input}.
 an encoding error occurs.
 \end{funcdesc}
 
+\begin{funcdesc}{iterencode}{iterable, encoding\optional{, errors}}
+Uses an incremental encoder to iteratively encode the input provided by
+\var{iterable}. This function is a generator. \var{errors} (as well as
+any other keyword argument) is passed through to the incremental encoder.
+\end{funcdesc}
+
+\begin{funcdesc}{iterdecode}{iterable, encoding\optional{, errors}}
+Uses an incremental decoder to iteratively decode the input provided by
+\var{iterable}. This function is a generator. \var{errors} (as well as
+any other keyword argument) is passed through to the incremental encoder.
+\end{funcdesc}
+
 The module also provides the following constants which are useful
 for reading and writing to platform dependent files:
 
@@ -292,6 +341,109 @@ function interfaces of the stateless encoder and decoder:
   empty object of the output object type in this situation.
 \end{methoddesc}
 
+The \class{IncrementalEncoder} and \class{IncrementalDecoder} classes provide
+the basic interface for incremental encoding and decoding. Encoding/decoding the
+input isn't done with one call to the stateless encoder/decoder function,
+but with multiple calls to the \method{encode}/\method{decode} method of the
+incremental encoder/decoder. The incremental encoder/decoder keeps track of
+the encoding/decoding process during method calls.
+
+The joined output of calls to the \method{encode}/\method{decode} method is the
+same as if the all single inputs where joined into one, and this input was
+encoded/decoded with the stateless encoder/decoder.
+
+
+\subsubsection{IncrementalEncoder Objects \label{incremental-encoder-objects}}
+
+The \class{IncrementalEncoder} class is used for encoding an input in multiple
+steps. It defines the following methods which every incremental encoder must
+define in order to be compatible to the Python codec registry.
+
+\begin{classdesc}{IncrementalEncoder}{\optional{errors}}
+  Constructor for a \class{IncrementalEncoder} instance.
+
+  All incremental encoders must provide this constructor interface. They are
+  free to add additional keyword arguments, but only the ones defined
+  here are used by the Python codec registry.
+
+  The \class{IncrementalEncoder} may implement different error handling
+  schemes by providing the \var{errors} keyword argument. These
+  parameters are predefined:
+
+  \begin{itemize}
+    \item \code{'strict'} Raise \exception{ValueError} (or a subclass);
+                          this is the default.
+    \item \code{'ignore'} Ignore the character and continue with the next.
+    \item \code{'replace'} Replace with a suitable replacement character
+    \item \code{'xmlcharrefreplace'} Replace with the appropriate XML
+                     character reference
+    \item \code{'backslashreplace'} Replace with backslashed escape sequences.
+  \end{itemize}
+
+  The \var{errors} argument will be assigned to an attribute of the
+  same name. Assigning to this attribute makes it possible to switch
+  between different error handling strategies during the lifetime
+  of the \class{IncrementalEncoder} object.
+
+  The set of allowed values for the \var{errors} argument can
+  be extended with \function{register_error()}.
+\end{classdesc}
+
+\begin{methoddesc}{encode}{object\optional{, final}}
+  Encodes \var{object} (taking the current state of the encoder into account)
+  and returns the resulting encoded object. If this is the last call to
+  \method{encode} \var{final} must be true (the default is false).
+\end{methoddesc}
+
+\begin{methoddesc}{reset}{}
+  Reset the encoder to the initial state.
+\end{methoddesc}
+
+
+\subsubsection{IncrementalDecoder Objects \label{incremental-decoder-objects}}
+
+The \class{IncrementalDecoder} class is used for decoding an input in multiple
+steps. It defines the following methods which every incremental decoder must
+define in order to be compatible to the Python codec registry.
+
+\begin{classdesc}{IncrementalDecoder}{\optional{errors}}
+  Constructor for a \class{IncrementalDecoder} instance.
+
+  All incremental decoders must provide this constructor interface. They are
+  free to add additional keyword arguments, but only the ones defined
+  here are used by the Python codec registry.
+
+  The \class{IncrementalDecoder} may implement different error handling
+  schemes by providing the \var{errors} keyword argument. These
+  parameters are predefined:
+
+  \begin{itemize}
+    \item \code{'strict'} Raise \exception{ValueError} (or a subclass);
+                          this is the default.
+    \item \code{'ignore'} Ignore the character and continue with the next.
+    \item \code{'replace'} Replace with a suitable replacement character.
+  \end{itemize}
+
+  The \var{errors} argument will be assigned to an attribute of the
+  same name. Assigning to this attribute makes it possible to switch
+  between different error handling strategies during the lifetime
+  of the \class{IncrementalEncoder} object.
+
+  The set of allowed values for the \var{errors} argument can
+  be extended with \function{register_error()}.
+\end{classdesc}
+
+\begin{methoddesc}{decode}{object\optional{, final}}
+  Decodes \var{object} (taking the current state of the decoder into account)
+  and returns the resulting decoded object. If this is the last call to
+  \method{decode} \var{final} must be true (the default is false).
+\end{methoddesc}
+
+\begin{methoddesc}{reset}{}
+  Reset the decoder to the initial state.
+\end{methoddesc}
+
+
 The \class{StreamWriter} and \class{StreamReader} classes provide
 generic working interfaces which can be used to implement new
 encodings submodules very easily. See \module{encodings.utf_8} for an
diff --git a/Include/codecs.h b/Include/codecs.h
index 82f18cd..0d76241 100644
--- a/Include/codecs.h
+++ b/Include/codecs.h
@@ -29,15 +29,15 @@ PyAPI_FUNC(int) PyCodec_Register(
 
 /* Codec register lookup API.
 
-   Looks up the given encoding and returns a tuple (encoder, decoder,
-   stream reader, stream writer) of functions which implement the
-   different aspects of processing the encoding.
+   Looks up the given encoding and returns a CodecInfo object with
+   function attributes which implement the different aspects of
+   processing the encoding.
 
    The encoding string is looked up converted to all lower-case
    characters. This makes encodings looked up through this mechanism
    effectively case-insensitive.
 
-   If no codec is found, a KeyError is set and NULL returned. 
+   If no codec is found, a KeyError is set and NULL returned.
 
    As side effect, this tries to load the encodings package, if not
    yet done. This is part of the lazy load strategy for the encodings
@@ -101,6 +101,20 @@ PyAPI_FUNC(PyObject *) PyCodec_Decoder(
        const char *encoding
        );
 
+/* Get a IncrementalEncoder object for the given encoding. */
+
+PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
+       const char *encoding,
+       const char *errors
+       );
+
+/* Get a IncrementalDecoder object function for the given encoding. */
+
+PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
+       const char *encoding,
+       const char *errors
+       );
+
 /* Get a StreamReader factory function for the given encoding. */
 
 PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
diff --git a/Lib/codecs.py b/Lib/codecs.py
index 6895a22..28856c7 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -73,6 +73,23 @@ BOM64_BE = BOM_UTF32_BE
 
 ### Codec base classes (defining the API)
 
+class CodecInfo(tuple):
+
+    def __new__(cls, encode, decode, streamreader=None, streamwriter=None,
+        incrementalencoder=None, incrementaldecoder=None, name=None):
+        self = tuple.__new__(cls, (encode, decode, streamreader, streamwriter))
+        self.name = name
+        self.encode = encode
+        self.decode = decode
+        self.incrementalencoder = incrementalencoder
+        self.incrementaldecoder = incrementaldecoder
+        self.streamwriter = streamwriter
+        self.streamreader = streamreader
+        return self
+
+    def __repr__(self):
+        return "<%s.%s object for encoding %s at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, id(self))
+
 class Codec:
 
     """ Defines the interface for stateless encoders/decoders.
@@ -137,6 +154,88 @@ class Codec:
         """
         raise NotImplementedError
 
+class IncrementalEncoder(object):
+    """
+    A IncrementalEncoder encodes an input in multiple steps. The input can be
+    passed piece by piece to the encode() method. The IncrementalEncoder remembers
+    the state of the Encoding process between calls to encode().
+    """
+    def __init__(self, errors='strict'):
+        """
+        Creates a IncrementalEncoder instance.
+
+        The IncrementalEncoder may use different error handling schemes by
+        providing the errors keyword argument. See the module docstring
+        for a list of possible values.
+        """
+        self.errors = errors
+        self.buffer = ""
+
+    def encode(self, input, final=False):
+        """
+        Encodes input and returns the resulting object.
+        """
+        raise NotImplementedError
+
+    def reset(self):
+        """
+        Resets the encoder to the initial state.
+        """
+
+class IncrementalDecoder(object):
+    """
+    An IncrementalDecoder decodes an input in multiple steps. The input can be
+    passed piece by piece to the decode() method. The IncrementalDecoder
+    remembers the state of the decoding process between calls to decode().
+    """
+    def __init__(self, errors='strict'):
+        """
+        Creates a IncrementalDecoder instance.
+
+        The IncrementalDecoder may use different error handling schemes by
+        providing the errors keyword argument. See the module docstring
+        for a list of possible values.
+        """
+        self.errors = errors
+
+    def decode(self, input, final=False):
+        """
+        Decodes input and returns the resulting object.
+        """
+        raise NotImplementedError
+
+    def reset(self):
+        """
+        Resets the decoder to the initial state.
+        """
+
+class BufferedIncrementalDecoder(IncrementalDecoder):
+    """
+    This subclass of IncrementalDecoder can be used as the baseclass for an
+    incremental decoder if the decoder must be able to handle incomplete byte
+    sequences.
+    """
+    def __init__(self, errors='strict'):
+        IncrementalDecoder.__init__(self, errors)
+        self.buffer = "" # undecoded input that is kept between calls to decode()
+
+    def _buffer_decode(self, input, errors, final):
+        # Overwrite this method in subclasses: It must decode input
+        # and return an (output, length consumed) tuple
+        raise NotImplementedError
+
+    def decode(self, input, final=False):
+        # decode input (taking the buffer into account)
+        data = self.buffer + input
+        (result, consumed) = self._buffer_decode(data, self.errors, final)
+        # keep undecoded input until the next call
+        self.buffer = data[consumed:]
+        return result
+
+    def reset(self):
+        IncrementalDecoder.reset(self)
+        self.bytebuffer = ""
+
 #
 # The StreamWriter and StreamReader class provide generic working
 # interfaces which can be used to implement new encoding submodules
@@ -666,8 +765,8 @@ def open(filename, mode='rb', encoding=None, errors='strict', buffering=1):
     file = __builtin__.open(filename, mode, buffering)
     if encoding is None:
         return file
-    (e, d, sr, sw) = lookup(encoding)
-    srw = StreamReaderWriter(file, sr, sw, errors)
+    info = lookup(encoding)
+    srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors)
     # Add attributes to simplify introspection
     srw.encoding = encoding
     return srw
@@ -699,11 +798,9 @@ def EncodedFile(file, data_encoding, file_encoding=None, errors='strict'):
     """
     if file_encoding is None:
         file_encoding = data_encoding
-    encode, decode = lookup(data_encoding)[:2]
-    Reader, Writer = lookup(file_encoding)[2:]
-    sr = StreamRecoder(file,
-                       encode, decode, Reader, Writer,
-                       errors)
+    info = lookup(data_encoding)
+    sr = StreamRecoder(file, info.encode, info.decode,
+                       info.streamreader, info.streamwriter, errors)
     # Add attributes to simplify introspection
     sr.data_encoding = data_encoding
     sr.file_encoding = file_encoding
@@ -719,7 +816,7 @@ def getencoder(encoding):
         Raises a LookupError in case the encoding cannot be found.
 
     """
-    return lookup(encoding)[0]
+    return lookup(encoding).encode
 
 def getdecoder(encoding):
 
@@ -729,7 +826,35 @@ def getdecoder(encoding):
         Raises a LookupError in case the encoding cannot be found.
 
     """
-    return lookup(encoding)[1]
+    return lookup(encoding).decode
+
+def getincrementalencoder(encoding):
+
+    """ Lookup up the codec for the given encoding and return
+        its IncrementalEncoder class or factory function.
+
+        Raises a LookupError in case the encoding cannot be found
+        or the codecs doesn't provide an incremental encoder.
+
+    """
+    encoder = lookup(encoding).incrementalencoder
+    if encoder is None:
+        raise LookupError(encoding)
+    return encoder
+
+def getincrementaldecoder(encoding):
+
+    """ Lookup up the codec for the given encoding and return
+        its IncrementalDecoder class or factory function.
+
+        Raises a LookupError in case the encoding cannot be found
+        or the codecs doesn't provide an incremental decoder.
+
+    """
+    decoder = lookup(encoding).incrementaldecoder
+    if decoder is None:
+        raise LookupError(encoding)
+    return decoder
 
 def getreader(encoding):
 
@@ -739,7 +864,7 @@ def getreader(encoding):
         Raises a LookupError in case the encoding cannot be found.
 
     """
-    return lookup(encoding)[2]
+    return lookup(encoding).streamreader
 
 def getwriter(encoding):
 
@@ -749,7 +874,43 @@ def getwriter(encoding):
         Raises a LookupError in case the encoding cannot be found.
 
     """
-    return lookup(encoding)[3]
+    return lookup(encoding).streamwriter
+
+def iterencode(iterator, encoding, errors='strict', **kwargs):
+    """
+    Encoding iterator.
+
+    Encodes the input strings from the iterator using a IncrementalEncoder.
+
+    errors and kwargs are passed through to the IncrementalEncoder
+    constructor.
+    """
+    encoder = getincrementalencoder(encoding)(errors, **kwargs)
+    for input in iterator:
+        output = encoder.encode(input)
+        if output:
+            yield output
+    output = encoder.encode("", True)
+    if output:
+        yield output
+
+def iterdecode(iterator, encoding, errors='strict', **kwargs):
+    """
+    Decoding iterator.
+
+    Decodes the input strings from the iterator using a IncrementalDecoder.
+
+    errors and kwargs are passed through to the IncrementalDecoder
+    constructor.
+    """
+    decoder = getincrementaldecoder(encoding)(errors, **kwargs)
+    for input in iterator:
+        output = decoder.decode(input)
+        if output:
+            yield output
+    output = decoder.decode("", True)
+    if output:
+        yield output
 
 ### Helpers for charmap-based codecs
 
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index ddaacb9..f8d2a2a 100644
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -9,9 +9,10 @@
 
     Each codec module must export the following interface:
 
-    * getregentry() -> (encoder, decoder, stream_reader, stream_writer)
-    The getregentry() API must return callable objects which adhere to
-    the Python Codec Interface Standard.
+    * getregentry() -> codecs.CodecInfo object
+    The getregentry() API must a CodecInfo object with encoder, decoder,
+    incrementalencoder, incrementaldecoder, streamwriter and streamreader
+    atttributes which adhere to the Python Codec Interface Standard.
 
     In addition, a module may optionally also define the following
     APIs which are then used by the package's codec search function:
@@ -113,16 +114,24 @@ def search_function(encoding):
         return None
 
     # Now ask the module for the registry entry
-    entry = tuple(getregentry())
-    if len(entry) != 4:
-        raise CodecRegistryError,\
-              'module "%s" (%s) failed to register' % \
-              (mod.__name__, mod.__file__)
-    for obj in entry:
-        if not callable(obj):
+    entry = getregentry()
+    if not isinstance(entry, codecs.CodecInfo):
+        if not 4 <= len(entry) <= 7:
+             raise CodecRegistryError,\
+                  'module "%s" (%s) failed to register' % \
+                   (mod.__name__, mod.__file__)
+        if not callable(entry[0]) or \
+           not callable(entry[1]) or \
+           (entry[2] is not None and not callable(entry[2])) or \
+           (entry[3] is not None and not callable(entry[3])) or \
+           (len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \
+           (len(entry) > 5 and entry[5] is not None and not callable(entry[5])):
             raise CodecRegistryError,\
-                  'incompatible codecs in module "%s" (%s)' % \
-                  (mod.__name__, mod.__file__)
+                'incompatible codecs in module "%s" (%s)' % \
+                (mod.__name__, mod.__file__)
+        if len(entry)<7 or entry[6] is None:
+            entry += (None,)*(6-len(entry)) + (mod.__name__.split(".", 1)[1],)
+        entry = codecs.CodecInfo(*entry)
 
     # Cache the codec registry entry
     _cache[encoding] = entry
diff --git a/Lib/encodings/ascii.py b/Lib/encodings/ascii.py
index 05fc36a..2033cde 100644
--- a/Lib/encodings/ascii.py
+++ b/Lib/encodings/ascii.py
@@ -17,6 +17,14 @@ class Codec(codecs.Codec):
     encode = codecs.ascii_encode
     decode = codecs.ascii_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.ascii_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.ascii_decode(input, self.errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -31,5 +39,12 @@ class StreamConverter(StreamWriter,StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='ascii',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/base64_codec.py b/Lib/encodings/base64_codec.py
index 085ab14..f84e780 100644
--- a/Lib/encodings/base64_codec.py
+++ b/Lib/encodings/base64_codec.py
@@ -49,6 +49,16 @@ class Codec(codecs.Codec):
     def decode(self, input,errors='strict'):
         return base64_decode(input,errors)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        assert self.errors == 'strict'
+        return base64.encodestring(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        assert self.errors == 'strict'
+        return base64.decodestring(input)
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -58,5 +68,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (base64_encode,base64_decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='base64',
+        encode=base64_encode,
+        decode=base64_decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/bz2_codec.py b/Lib/encodings/bz2_codec.py
index 870474c..81e84b6 100644
--- a/Lib/encodings/bz2_codec.py
+++ b/Lib/encodings/bz2_codec.py
@@ -51,6 +51,16 @@ class Codec(codecs.Codec):
     def decode(self, input, errors='strict'):
         return bz2_decode(input, errors)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        assert self.errors == 'strict'
+        return bz2.compress(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        assert self.errors == 'strict'
+        return bz2.decompress(input)
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -60,5 +70,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (bz2_encode,bz2_decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name="bz2",
+        encode=bz2_encode,
+        decode=bz2_decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/charmap.py b/Lib/encodings/charmap.py
index 9bd93ec..81189b1 100644
--- a/Lib/encodings/charmap.py
+++ b/Lib/encodings/charmap.py
@@ -21,30 +21,49 @@ class Codec(codecs.Codec):
     encode = codecs.charmap_encode
     decode = codecs.charmap_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def __init__(self, errors='strict', mapping=None):
+        codecs.IncrementalEncoder.__init__(self, errors)
+        self.mapping = mapping
+
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input, self.errors, self.mapping)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def __init__(self, errors='strict', mapping=None):
+        codecs.IncrementalDecoder.__init__(self, errors)
+        self.mapping = mapping
+
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input, self.errors, self.mapping)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
 
     def __init__(self,stream,errors='strict',mapping=None):
-
         codecs.StreamWriter.__init__(self,stream,errors)
         self.mapping = mapping
 
     def encode(self,input,errors='strict'):
-
         return Codec.encode(input,errors,self.mapping)
 
 class StreamReader(Codec,codecs.StreamReader):
 
     def __init__(self,stream,errors='strict',mapping=None):
-
         codecs.StreamReader.__init__(self,stream,errors)
         self.mapping = mapping
 
     def decode(self,input,errors='strict'):
-
         return Codec.decode(input,errors,self.mapping)
 
 ### encodings module API
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='charmap',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/cp037.py b/Lib/encodings/cp037.py
index 5864c4b..4700a8c 100644
--- a/Lib/encodings/cp037.py
+++ b/Lib/encodings/cp037.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP037.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp037 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP037.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp037',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x00FE: 0x8E,       #  LATIN SMALL LETTER THORN (ICELANDIC)
     0x00FF: 0xDF,       #  LATIN SMALL LETTER Y WITH DIAERESIS
 }
+
diff --git a/Lib/encodings/cp1006.py b/Lib/encodings/cp1006.py
index d94563d..9813e7e 100644
--- a/Lib/encodings/cp1006.py
+++ b/Lib/encodings/cp1006.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/CP1006.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1006 generated from 'MAPPINGS/VENDORS/MISC/CP1006.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1006',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -549,3 +562,4 @@ encoding_map = {
     0xFEF2: 0xFA,       #  ARABIC LETTER YEH FINAL FORM
     0xFEF3: 0xFB,       #  ARABIC LETTER YEH INITIAL FORM
 }
+
diff --git a/Lib/encodings/cp1026.py b/Lib/encodings/cp1026.py
index 648bed0..7014393 100644
--- a/Lib/encodings/cp1026.py
+++ b/Lib/encodings/cp1026.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP1026.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1026 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP1026.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1026',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x015E: 0x7C,       #  LATIN CAPITAL LETTER S WITH CEDILLA
     0x015F: 0x6A,       #  LATIN SMALL LETTER S WITH CEDILLA
 }
+
diff --git a/Lib/encodings/cp1140.py b/Lib/encodings/cp1140.py
index 6507552..09b70b2 100644
--- a/Lib/encodings/cp1140.py
+++ b/Lib/encodings/cp1140.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'python-mappings/CP1140.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1140 generated from 'python-mappings/CP1140.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1140',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x00FF: 0xDF,       #  LATIN SMALL LETTER Y WITH DIAERESIS
     0x20AC: 0x9F,       #  EURO SIGN
 }
+
diff --git a/Lib/encodings/cp1250.py b/Lib/encodings/cp1250.py
index 73427bc..8eadbbf 100644
--- a/Lib/encodings/cp1250.py
+++ b/Lib/encodings/cp1250.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1250 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1250',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -545,3 +558,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1251.py b/Lib/encodings/cp1251.py
index f3e107ef..517a554 100644
--- a/Lib/encodings/cp1251.py
+++ b/Lib/encodings/cp1251.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1251 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1251',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -549,3 +562,4 @@ encoding_map = {
     0x2116: 0xB9,       #  NUMERO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1252.py b/Lib/encodings/cp1252.py
index ea7561d..c695443 100644
--- a/Lib/encodings/cp1252.py
+++ b/Lib/encodings/cp1252.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1252 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1252',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -545,3 +558,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1253.py b/Lib/encodings/cp1253.py
index 5feefb3..693407a 100644
--- a/Lib/encodings/cp1253.py
+++ b/Lib/encodings/cp1253.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1253.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1253 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1253.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1253',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -533,3 +546,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1254.py b/Lib/encodings/cp1254.py
index 6769e1b..cb71f4b 100644
--- a/Lib/encodings/cp1254.py
+++ b/Lib/encodings/cp1254.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1254.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1254 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1254.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1254',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -543,3 +556,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1255.py b/Lib/encodings/cp1255.py
index b994f9d..376e797 100644
--- a/Lib/encodings/cp1255.py
+++ b/Lib/encodings/cp1255.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1255 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1255',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -527,3 +540,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1256.py b/Lib/encodings/cp1256.py
index 5da425e..bb6895f 100644
--- a/Lib/encodings/cp1256.py
+++ b/Lib/encodings/cp1256.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1256 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1256',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1257.py b/Lib/encodings/cp1257.py
index 237a531..08a3fb9 100644
--- a/Lib/encodings/cp1257.py
+++ b/Lib/encodings/cp1257.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1257 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1257',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -538,3 +551,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp1258.py b/Lib/encodings/cp1258.py
index 5de3fd8..eecfcbf 100644
--- a/Lib/encodings/cp1258.py
+++ b/Lib/encodings/cp1258.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp1258 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp1258',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -541,3 +554,4 @@ encoding_map = {
     0x20AC: 0x80,       #  EURO SIGN
     0x2122: 0x99,       #  TRADE MARK SIGN
 }
+
diff --git a/Lib/encodings/cp424.py b/Lib/encodings/cp424.py
index d19c756..9812ccd 100644
--- a/Lib/encodings/cp424.py
+++ b/Lib/encodings/cp424.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/CP424.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp424 generated from 'MAPPINGS/VENDORS/MISC/CP424.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp424',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -512,3 +525,4 @@ encoding_map = {
     0x05EA: 0x71,       #  HEBREW LETTER TAV
     0x2017: 0x78,       #  DOUBLE LOW LINE
 }
+
diff --git a/Lib/encodings/cp437.py b/Lib/encodings/cp437.py
index e9cefaf..52cd882 100644
--- a/Lib/encodings/cp437.py
+++ b/Lib/encodings/cp437.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP437.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp437 generated from 'VENDORS/MICSFT/PC/CP437.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp437',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp500.py b/Lib/encodings/cp500.py
index 3bbefa0..5b843d1 100644
--- a/Lib/encodings/cp500.py
+++ b/Lib/encodings/cp500.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP500.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp500 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP500.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp500',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x00FE: 0x8E,       #  LATIN SMALL LETTER THORN (ICELANDIC)
     0x00FF: 0xDF,       #  LATIN SMALL LETTER Y WITH DIAERESIS
 }
+
diff --git a/Lib/encodings/cp737.py b/Lib/encodings/cp737.py
index 883a8ba..d654448 100644
--- a/Lib/encodings/cp737.py
+++ b/Lib/encodings/cp737.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP737.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp737 generated from 'VENDORS/MICSFT/PC/CP737.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp737',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp775.py b/Lib/encodings/cp775.py
index 1b39188..6a456a5 100644
--- a/Lib/encodings/cp775.py
+++ b/Lib/encodings/cp775.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP775.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp775 generated from 'VENDORS/MICSFT/PC/CP775.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,9 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
-
+    return codecs.CodecInfo(
+        name='cp775',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 ### Decoding Map
 
 decoding_map = codecs.make_identity_dict(range(256))
diff --git a/Lib/encodings/cp850.py b/Lib/encodings/cp850.py
index 6481ee0..0c8478c 100644
--- a/Lib/encodings/cp850.py
+++ b/Lib/encodings/cp850.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp850',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp852.py b/Lib/encodings/cp852.py
index 749b0da..069d547 100644
--- a/Lib/encodings/cp852.py
+++ b/Lib/encodings/cp852.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp852',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp855.py b/Lib/encodings/cp855.py
index 13146c9..241ef9d 100644
--- a/Lib/encodings/cp855.py
+++ b/Lib/encodings/cp855.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp855',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp856.py b/Lib/encodings/cp856.py
index 5823dff..7941b27 100644
--- a/Lib/encodings/cp856.py
+++ b/Lib/encodings/cp856.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/CP856.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp856 generated from 'MAPPINGS/VENDORS/MISC/CP856.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp856',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -509,3 +522,4 @@ encoding_map = {
     0x2593: 0xB2,       #  DARK SHADE
     0x25A0: 0xFE,       #  BLACK SQUARE
 }
+
diff --git a/Lib/encodings/cp857.py b/Lib/encodings/cp857.py
index 6c5cdbb..c24191b 100644
--- a/Lib/encodings/cp857.py
+++ b/Lib/encodings/cp857.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp857',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp860.py b/Lib/encodings/cp860.py
index cd7cdf4..4acb0cf 100644
--- a/Lib/encodings/cp860.py
+++ b/Lib/encodings/cp860.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp860',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp861.py b/Lib/encodings/cp861.py
index b140f2e..0939b5b 100644
--- a/Lib/encodings/cp861.py
+++ b/Lib/encodings/cp861.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp861',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp862.py b/Lib/encodings/cp862.py
index badec08..ea0405c 100644
--- a/Lib/encodings/cp862.py
+++ b/Lib/encodings/cp862.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp862',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp863.py b/Lib/encodings/cp863.py
index 812bc3d..62dfabf 100644
--- a/Lib/encodings/cp863.py
+++ b/Lib/encodings/cp863.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp863',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp864.py b/Lib/encodings/cp864.py
index 41f2ea3..02a0e73 100644
--- a/Lib/encodings/cp864.py
+++ b/Lib/encodings/cp864.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp864',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp865.py b/Lib/encodings/cp865.py
index 8e68c6b..e9f45f1 100644
--- a/Lib/encodings/cp865.py
+++ b/Lib/encodings/cp865.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp865',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp866.py b/Lib/encodings/cp866.py
index 4c0dd8c..29cd85a 100644
--- a/Lib/encodings/cp866.py
+++ b/Lib/encodings/cp866.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp866',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp869.py b/Lib/encodings/cp869.py
index 1747546..b4dc99b 100644
--- a/Lib/encodings/cp869.py
+++ b/Lib/encodings/cp869.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp869',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/cp874.py b/Lib/encodings/cp874.py
index 5e1fea1..d2de389 100644
--- a/Lib/encodings/cp874.py
+++ b/Lib/encodings/cp874.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP874.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp874 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP874.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp874',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -519,3 +532,4 @@ encoding_map = {
     0x2026: 0x85,       #  HORIZONTAL ELLIPSIS
     0x20AC: 0x80,       #  EURO SIGN
 }
+
diff --git a/Lib/encodings/cp875.py b/Lib/encodings/cp875.py
index ccebb84..3f24fd3 100644
--- a/Lib/encodings/cp875.py
+++ b/Lib/encodings/cp875.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP875.TXT' with gencodec.py.
+""" Python Character Mapping Codec cp875 generated from 'MAPPINGS/VENDORS/MICSFT/EBCDIC/CP875.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='cp875',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -544,3 +557,4 @@ encoding_map = {
     0x2018: 0xCE,       #  LEFT SINGLE QUOTATION MARK
     0x2019: 0xDE,       #  RIGHT SINGLE QUOTATION MARK
 }
+
diff --git a/Lib/encodings/hex_codec.py b/Lib/encodings/hex_codec.py
index 5c6e4a4..91b38d9 100644
--- a/Lib/encodings/hex_codec.py
+++ b/Lib/encodings/hex_codec.py
@@ -49,6 +49,16 @@ class Codec(codecs.Codec):
     def decode(self, input,errors='strict'):
         return hex_decode(input,errors)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        assert self.errors == 'strict'
+        return binascii.b2a_hex(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        assert self.errors == 'strict'
+        return binascii.a2b_hex(input)
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -58,5 +68,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (hex_encode,hex_decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='hex',
+        encode=hex_encode,
+        decode=hex_decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/hp_roman8.py b/Lib/encodings/hp_roman8.py
index 4f201b8..dbaaa72 100644
--- a/Lib/encodings/hp_roman8.py
+++ b/Lib/encodings/hp_roman8.py
@@ -14,13 +14,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_map)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_map)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='hp-roman8',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py
index 3d3ed23..8bdae32 100644
--- a/Lib/encodings/idna.py
+++ b/Lib/encodings/idna.py
@@ -194,6 +194,14 @@ class Codec(codecs.Codec):
 
         return u".".join(result)+trailing_dot, len(input)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return Codec().encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return Codec().decode(input, self.errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -203,5 +211,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='idna',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/iso8859_1.py b/Lib/encodings/iso8859_1.py
index 6aaea7c..8eb98c2 100644
--- a/Lib/encodings/iso8859_1.py
+++ b/Lib/encodings/iso8859_1.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-1.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_1 generated from 'MAPPINGS/ISO8859/8859-1.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-1',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x00FE: 0xFE,       #  LATIN SMALL LETTER THORN (Icelandic)
     0x00FF: 0xFF,       #  LATIN SMALL LETTER Y WITH DIAERESIS
 }
+
diff --git a/Lib/encodings/iso8859_10.py b/Lib/encodings/iso8859_10.py
index 26b55c9..ff2c6db 100644
--- a/Lib/encodings/iso8859_10.py
+++ b/Lib/encodings/iso8859_10.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-10.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_10 generated from 'MAPPINGS/ISO8859/8859-10.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-10',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x017E: 0xBC,       #  LATIN SMALL LETTER Z WITH CARON
     0x2015: 0xBD,       #  HORIZONTAL BAR
 }
+
diff --git a/Lib/encodings/iso8859_11.py b/Lib/encodings/iso8859_11.py
index ef17167..a487291 100644
--- a/Lib/encodings/iso8859_11.py
+++ b/Lib/encodings/iso8859_11.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-11.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_11 generated from 'MAPPINGS/ISO8859/8859-11.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-11',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -542,3 +555,4 @@ encoding_map = {
     0x0E5A: 0xFA,       #  THAI CHARACTER ANGKHANKHU
     0x0E5B: 0xFB,       #  THAI CHARACTER KHOMUT
 }
+
diff --git a/Lib/encodings/iso8859_13.py b/Lib/encodings/iso8859_13.py
index 0e10c7d..fc59d04 100644
--- a/Lib/encodings/iso8859_13.py
+++ b/Lib/encodings/iso8859_13.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-13.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_13 generated from 'MAPPINGS/ISO8859/8859-13.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-13',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x201D: 0xA1,       #  RIGHT DOUBLE QUOTATION MARK
     0x201E: 0xA5,       #  DOUBLE LOW-9 QUOTATION MARK
 }
+
diff --git a/Lib/encodings/iso8859_14.py b/Lib/encodings/iso8859_14.py
index b981031..f8d9637 100644
--- a/Lib/encodings/iso8859_14.py
+++ b/Lib/encodings/iso8859_14.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-14.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_14 generated from 'MAPPINGS/ISO8859/8859-14.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-14',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x1EF2: 0xAC,       #  LATIN CAPITAL LETTER Y WITH GRAVE
     0x1EF3: 0xBC,       #  LATIN SMALL LETTER Y WITH GRAVE
 }
+
diff --git a/Lib/encodings/iso8859_15.py b/Lib/encodings/iso8859_15.py
index f50a904..5e01238 100644
--- a/Lib/encodings/iso8859_15.py
+++ b/Lib/encodings/iso8859_15.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-15.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_15 generated from 'MAPPINGS/ISO8859/8859-15.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-15',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x017E: 0xB8,       #  LATIN SMALL LETTER Z WITH CARON
     0x20AC: 0xA4,       #  EURO SIGN
 }
+
diff --git a/Lib/encodings/iso8859_16.py b/Lib/encodings/iso8859_16.py
index ce8bc5b..0578a21 100644
--- a/Lib/encodings/iso8859_16.py
+++ b/Lib/encodings/iso8859_16.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-16.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_16 generated from 'MAPPINGS/ISO8859/8859-16.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-16',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x201E: 0xA5,       #  DOUBLE LOW-9 QUOTATION MARK
     0x20AC: 0xA4,       #  EURO SIGN
 }
+
diff --git a/Lib/encodings/iso8859_2.py b/Lib/encodings/iso8859_2.py
index 417b451..85a5b63 100644
--- a/Lib/encodings/iso8859_2.py
+++ b/Lib/encodings/iso8859_2.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-2.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_2 generated from 'MAPPINGS/ISO8859/8859-2.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-2',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x02DB: 0xB2,       #  OGONEK
     0x02DD: 0xBD,       #  DOUBLE ACUTE ACCENT
 }
+
diff --git a/Lib/encodings/iso8859_3.py b/Lib/encodings/iso8859_3.py
index c3ad3a9..cac335d 100644
--- a/Lib/encodings/iso8859_3.py
+++ b/Lib/encodings/iso8859_3.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-3.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_3 generated from 'MAPPINGS/ISO8859/8859-3.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-3',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -543,3 +556,4 @@ encoding_map = {
     0x02D8: 0xA2,       #  BREVE
     0x02D9: 0xFF,       #  DOT ABOVE
 }
+
diff --git a/Lib/encodings/iso8859_4.py b/Lib/encodings/iso8859_4.py
index b65685a..ecd7fb2 100644
--- a/Lib/encodings/iso8859_4.py
+++ b/Lib/encodings/iso8859_4.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-4.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_4 generated from 'MAPPINGS/ISO8859/8859-4.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-4',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x02D9: 0xFF,       #  DOT ABOVE
     0x02DB: 0xB2,       #  OGONEK
 }
+
diff --git a/Lib/encodings/iso8859_5.py b/Lib/encodings/iso8859_5.py
index 59fe372..4e377df 100644
--- a/Lib/encodings/iso8859_5.py
+++ b/Lib/encodings/iso8859_5.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-5.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_5 generated from 'MAPPINGS/ISO8859/8859-5.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-5',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x045F: 0xFF,       #  CYRILLIC SMALL LETTER DZHE
     0x2116: 0xF0,       #  NUMERO SIGN
 }
+
diff --git a/Lib/encodings/iso8859_6.py b/Lib/encodings/iso8859_6.py
index b07661d9..ca5b125 100644
--- a/Lib/encodings/iso8859_6.py
+++ b/Lib/encodings/iso8859_6.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-6.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_6 generated from 'MAPPINGS/ISO8859/8859-6.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-6',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -505,3 +518,4 @@ encoding_map = {
     0x0651: 0xF1,       #  ARABIC SHADDA
     0x0652: 0xF2,       #  ARABIC SUKUN
 }
+
diff --git a/Lib/encodings/iso8859_7.py b/Lib/encodings/iso8859_7.py
index 54d0997..d1adb48 100644
--- a/Lib/encodings/iso8859_7.py
+++ b/Lib/encodings/iso8859_7.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-7.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_7 generated from 'MAPPINGS/ISO8859/8859-7.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-7',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -547,3 +560,4 @@ encoding_map = {
     0x20AC: 0xA4,       #  EURO SIGN
     0x20AF: 0xA5,       #  DRACHMA SIGN
 }
+
diff --git a/Lib/encodings/iso8859_8.py b/Lib/encodings/iso8859_8.py
index 24ba1bb..d935092 100644
--- a/Lib/encodings/iso8859_8.py
+++ b/Lib/encodings/iso8859_8.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-8.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_8 generated from 'MAPPINGS/ISO8859/8859-8.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-8',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -514,3 +527,4 @@ encoding_map = {
     0x200F: 0xFE,       #  RIGHT-TO-LEFT MARK
     0x2017: 0xDF,       #  DOUBLE LOW LINE
 }
+
diff --git a/Lib/encodings/iso8859_9.py b/Lib/encodings/iso8859_9.py
index 940d92b..d2bb92c 100644
--- a/Lib/encodings/iso8859_9.py
+++ b/Lib/encodings/iso8859_9.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/ISO8859/8859-9.TXT' with gencodec.py.
+""" Python Character Mapping Codec iso8859_9 generated from 'MAPPINGS/ISO8859/8859-9.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='iso8859-9',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x015E: 0xDE,       #  LATIN CAPITAL LETTER S WITH CEDILLA
     0x015F: 0xFE,       #  LATIN SMALL LETTER S WITH CEDILLA
 }
+
diff --git a/Lib/encodings/koi8_r.py b/Lib/encodings/koi8_r.py
index f2723de..fa0fcdb 100644
--- a/Lib/encodings/koi8_r.py
+++ b/Lib/encodings/koi8_r.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/MISC/KOI8-R.TXT' with gencodec.py.
+""" Python Character Mapping Codec koi8_r generated from 'MAPPINGS/VENDORS/MISC/KOI8-R.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='koi8-r',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x2593: 0x92,       #  DARK SHADE
     0x25A0: 0x94,       #  BLACK SQUARE
 }
+
diff --git a/Lib/encodings/koi8_u.py b/Lib/encodings/koi8_u.py
index 9bbcf7c..4709d9c 100644
--- a/Lib/encodings/koi8_u.py
+++ b/Lib/encodings/koi8_u.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'python-mappings/KOI8-U.TXT' with gencodec.py.
+""" Python Character Mapping Codec koi8_u generated from 'python-mappings/KOI8-U.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='koi8-u',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x2593: 0x92,       #  DARK SHADE
     0x25A0: 0x94,       #  BLACK SQUARE
 }
+
diff --git a/Lib/encodings/latin_1.py b/Lib/encodings/latin_1.py
index 0e55917..b2a0839 100644
--- a/Lib/encodings/latin_1.py
+++ b/Lib/encodings/latin_1.py
@@ -17,6 +17,14 @@ class Codec(codecs.Codec):
     encode = codecs.latin_1_encode
     decode = codecs.latin_1_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.latin_1_encode(input,self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.latin_1_decode(input,self.errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -31,5 +39,13 @@ class StreamConverter(StreamWriter,StreamReader):
 ### encodings module API
 
 def getregentry():
+    return codecs.CodecInfo(
+        name='iso8859-1',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
diff --git a/Lib/encodings/mac_arabic.py b/Lib/encodings/mac_arabic.py
index 6c096b4..7a7d3c5 100644
--- a/Lib/encodings/mac_arabic.py
+++ b/Lib/encodings/mac_arabic.py
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-arabic',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/mac_centeuro.py b/Lib/encodings/mac_centeuro.py
index d7d67ec..241712e 100644
--- a/Lib/encodings/mac_centeuro.py
+++ b/Lib/encodings/mac_centeuro.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/CENTEURO.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_centeuro generated from 'MAPPINGS/VENDORS/APPLE/CENTEURO.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-centeuro',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x2265: 0xB3,       #  GREATER-THAN OR EQUAL TO
     0x25CA: 0xD7,       #  LOZENGE
 }
+
diff --git a/Lib/encodings/mac_croatian.py b/Lib/encodings/mac_croatian.py
index 96e1187..6ef72ae 100644
--- a/Lib/encodings/mac_croatian.py
+++ b/Lib/encodings/mac_croatian.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/CROATIAN.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_croatian generated from 'MAPPINGS/VENDORS/APPLE/CROATIAN.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-croatian',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x25CA: 0xD7,       #  LOZENGE
     0xF8FF: 0xD8,       #  Apple logo
 }
+
diff --git a/Lib/encodings/mac_cyrillic.py b/Lib/encodings/mac_cyrillic.py
index f1b1fb0..ada395c 100644
--- a/Lib/encodings/mac_cyrillic.py
+++ b/Lib/encodings/mac_cyrillic.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/CYRILLIC.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_cyrillic generated from 'MAPPINGS/VENDORS/APPLE/CYRILLIC.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-cyrillic',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x2264: 0xB2,       #  LESS-THAN OR EQUAL TO
     0x2265: 0xB3,       #  GREATER-THAN OR EQUAL TO
 }
+
diff --git a/Lib/encodings/mac_farsi.py b/Lib/encodings/mac_farsi.py
index 2b61e27..c83b6ad 100644
--- a/Lib/encodings/mac_farsi.py
+++ b/Lib/encodings/mac_farsi.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/FARSI.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_farsi generated from 'MAPPINGS/VENDORS/APPLE/FARSI.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-farsi',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x2026: 0x93,       #  HORIZONTAL ELLIPSIS, right-left
     0x274A: 0xC0,       #  EIGHT TEARDROP-SPOKED PROPELLER ASTERISK, right-left
 }
+
diff --git a/Lib/encodings/mac_greek.py b/Lib/encodings/mac_greek.py
index c2dd26f..aa1894b 100644
--- a/Lib/encodings/mac_greek.py
+++ b/Lib/encodings/mac_greek.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/GREEK.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_greek generated from 'MAPPINGS/VENDORS/APPLE/GREEK.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-greek',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x2264: 0xB2,       #  LESS-THAN OR EQUAL TO
     0x2265: 0xB3,       #  GREATER-THAN OR EQUAL TO
 }
+
diff --git a/Lib/encodings/mac_iceland.py b/Lib/encodings/mac_iceland.py
index d305d29..0c3f054 100644
--- a/Lib/encodings/mac_iceland.py
+++ b/Lib/encodings/mac_iceland.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/ICELAND.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_iceland generated from 'MAPPINGS/VENDORS/APPLE/ICELAND.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-iceland',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x25CA: 0xD7,       #  LOZENGE
     0xF8FF: 0xF0,       #  Apple logo
 }
+
diff --git a/Lib/encodings/mac_latin2.py b/Lib/encodings/mac_latin2.py
index f5d5225..e322be2 100644
--- a/Lib/encodings/mac_latin2.py
+++ b/Lib/encodings/mac_latin2.py
@@ -14,13 +14,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_map)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_map)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-latin2',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/mac_roman.py b/Lib/encodings/mac_roman.py
index d23aeba..2de8ab5 100644
--- a/Lib/encodings/mac_roman.py
+++ b/Lib/encodings/mac_roman.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/ROMAN.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_roman generated from 'MAPPINGS/VENDORS/APPLE/ROMAN.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-roman',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0xFB01: 0xDE,       #  LATIN SMALL LIGATURE FI
     0xFB02: 0xDF,       #  LATIN SMALL LIGATURE FL
 }
+
diff --git a/Lib/encodings/mac_romanian.py b/Lib/encodings/mac_romanian.py
index 5c35a64..f8826de 100644
--- a/Lib/encodings/mac_romanian.py
+++ b/Lib/encodings/mac_romanian.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/ROMANIAN.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_romanian generated from 'MAPPINGS/VENDORS/APPLE/ROMANIAN.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-romanian',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0x25CA: 0xD7,       #  LOZENGE
     0xF8FF: 0xF0,       #  Apple logo
 }
+
diff --git a/Lib/encodings/mac_turkish.py b/Lib/encodings/mac_turkish.py
index 79894ba..aee3f7e 100644
--- a/Lib/encodings/mac_turkish.py
+++ b/Lib/encodings/mac_turkish.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'MAPPINGS/VENDORS/APPLE/TURKISH.TXT' with gencodec.py.
+""" Python Character Mapping Codec mac_turkish generated from 'MAPPINGS/VENDORS/APPLE/TURKISH.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mac-turkish',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -550,3 +563,4 @@ encoding_map = {
     0xF8A0: 0xF5,       #  undefined1
     0xF8FF: 0xF0,       #  Apple logo
 }
+
diff --git a/Lib/encodings/mbcs.py b/Lib/encodings/mbcs.py
index c79f47c..14db973 100644
--- a/Lib/encodings/mbcs.py
+++ b/Lib/encodings/mbcs.py
@@ -18,6 +18,13 @@ class Codec(codecs.Codec):
     encode = codecs.mbcs_encode
     decode = codecs.mbcs_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.mbs_encode(input,self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.mbs_decode(input,self.errors)[0]
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -32,5 +39,12 @@ class StreamConverter(StreamWriter,StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='mbcs',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/encodings/palmos.py b/Lib/encodings/palmos.py
index c0f0606..4b77e2b 100644
--- a/Lib/encodings/palmos.py
+++ b/Lib/encodings/palmos.py
@@ -15,6 +15,14 @@ class Codec(codecs.Codec):
     def decode(self,input,errors='strict'):
         return codecs.charmap_decode(input,errors,decoding_map)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_map)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -24,7 +32,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='palmos',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/ptcp154.py b/Lib/encodings/ptcp154.py
index 5cdd98c..aef8975 100644
--- a/Lib/encodings/ptcp154.py
+++ b/Lib/encodings/ptcp154.py
@@ -14,13 +14,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_map)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_map)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='ptcp154',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/punycode.py b/Lib/encodings/punycode.py
index 82fd458..2cde8b9 100644
--- a/Lib/encodings/punycode.py
+++ b/Lib/encodings/punycode.py
@@ -197,18 +197,27 @@ def punycode_decode(text, errors):
 ### Codec APIs
 
 class Codec(codecs.Codec):
-    def encode(self,input,errors='strict'):
 
+    def encode(self,input,errors='strict'):
         res = punycode_encode(input)
         return res, len(input)
 
     def decode(self,input,errors='strict'):
-
         if errors not in ('strict', 'replace', 'ignore'):
             raise UnicodeError, "Unsupported error handling "+errors
         res = punycode_decode(input, errors)
         return res, len(input)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return punycode_encode(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        if errors not in ('strict', 'replace', 'ignore'):
+            raise UnicodeError, "Unsupported error handling "+errors
+        return punycode_decode(input, errors)
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -218,5 +227,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='punycode',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/quopri_codec.py b/Lib/encodings/quopri_codec.py
index d98b5ed..b802ae6 100644
--- a/Lib/encodings/quopri_codec.py
+++ b/Lib/encodings/quopri_codec.py
@@ -46,6 +46,14 @@ class Codec(codecs.Codec):
     def decode(self, input,errors='strict'):
         return quopri_decode(input,errors)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return quopri_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return quopri_decode(input, self.errors)[0]
+
 class StreamWriter(Codec, codecs.StreamWriter):
     pass
 
@@ -55,4 +63,12 @@ class StreamReader(Codec,codecs.StreamReader):
 # encodings module API
 
 def getregentry():
-    return (quopri_encode, quopri_decode, StreamReader, StreamWriter)
+    return codecs.CodecInfo(
+        name='quopri',
+        encode=quopri_encode,
+        decode=quopri_decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/raw_unicode_escape.py b/Lib/encodings/raw_unicode_escape.py
index a2f3fff..2b919b4 100644
--- a/Lib/encodings/raw_unicode_escape.py
+++ b/Lib/encodings/raw_unicode_escape.py
@@ -17,6 +17,14 @@ class Codec(codecs.Codec):
     encode = codecs.raw_unicode_escape_encode
     decode = codecs.raw_unicode_escape_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.raw_unicode_escape_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.raw_unicode_escape_decode(input, self.errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -26,5 +34,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='raw-unicode-escape',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/rot_13.py b/Lib/encodings/rot_13.py
index c628181..52b6431 100644
--- a/Lib/encodings/rot_13.py
+++ b/Lib/encodings/rot_13.py
@@ -14,13 +14,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_map)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_map)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -30,8 +36,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='rot-13',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
 
 ### Decoding Map
 
diff --git a/Lib/encodings/string_escape.py b/Lib/encodings/string_escape.py
index c02bfee..e329a26 100644
--- a/Lib/encodings/string_escape.py
+++ b/Lib/encodings/string_escape.py
@@ -12,6 +12,14 @@ class Codec(codecs.Codec):
     encode = codecs.escape_encode
     decode = codecs.escape_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.escape_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.escape_decode(input, self.errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -19,5 +27,12 @@ class StreamReader(Codec,codecs.StreamReader):
     pass
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='string-escape',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/tis_620.py b/Lib/encodings/tis_620.py
index aa1823e..b0a8e4c 100644
--- a/Lib/encodings/tis_620.py
+++ b/Lib/encodings/tis_620.py
@@ -1,4 +1,4 @@
-""" Python Character Mapping Codec generated from 'python-mappings/TIS-620.TXT' with gencodec.py.
+""" Python Character Mapping Codec tis_620 generated from 'python-mappings/TIS-620.TXT' with gencodec.py.
 
 """#"
 
@@ -9,13 +9,19 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
     def decode(self,input,errors='strict'):
-
         return codecs.charmap_decode(input,errors,decoding_table)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -25,8 +31,15 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='tis-620',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
 
 
 ### Decoding Table
@@ -541,3 +554,4 @@ encoding_map = {
     0x0E5A: 0xFA,       #  THAI CHARACTER ANGKHANKHU
     0x0E5B: 0xFB,       #  THAI CHARACTER KHOMUT
 }
+
diff --git a/Lib/encodings/undefined.py b/Lib/encodings/undefined.py
index d2277ac..4690288 100644
--- a/Lib/encodings/undefined.py
+++ b/Lib/encodings/undefined.py
@@ -16,10 +16,18 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-        raise UnicodeError, "undefined encoding"
+        raise UnicodeError("undefined encoding")
 
     def decode(self,input,errors='strict'):
-        raise UnicodeError, "undefined encoding"
+        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")
 
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
@@ -30,5 +38,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='undefined',
+        encode=Codec().encode,
+        decode=Codec().decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/unicode_escape.py b/Lib/encodings/unicode_escape.py
index 8fb6293..817f932 100644
--- a/Lib/encodings/unicode_escape.py
+++ b/Lib/encodings/unicode_escape.py
@@ -17,6 +17,14 @@ class Codec(codecs.Codec):
     encode = codecs.unicode_escape_encode
     decode = codecs.unicode_escape_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.unicode_escape_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.unicode_escape_decode(input, self.errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -26,5 +34,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='unicode-escape',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/unicode_internal.py b/Lib/encodings/unicode_internal.py
index 3bd2fa0..df3e775 100644
--- a/Lib/encodings/unicode_internal.py
+++ b/Lib/encodings/unicode_internal.py
@@ -17,6 +17,14 @@ class Codec(codecs.Codec):
     encode = codecs.unicode_internal_encode
     decode = codecs.unicode_internal_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.unicode_internal_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return codecs.unicode_internal_decode(input, self.errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -26,5 +34,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='unicode-internal',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+    )
diff --git a/Lib/encodings/utf_16.py b/Lib/encodings/utf_16.py
index 95abb05..eff08f3 100644
--- a/Lib/encodings/utf_16.py
+++ b/Lib/encodings/utf_16.py
@@ -15,6 +15,47 @@ encode = codecs.utf_16_encode
 def decode(input, errors='strict'):
     return codecs.utf_16_decode(input, errors, True)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def __init__(self, errors='strict'):
+        codecs.IncrementalEncoder.__init__(self, errors)
+        self.encoder = None
+
+    def encode(self, input, final=False):
+        if self.encoder is None:
+            result = codecs.utf_16_encode(input, self.errors)[0]
+            if sys.byteorder == 'little':
+                self.encoder = codecs.utf_16_le_encode
+            else:
+                self.encoder = codecs.utf_16_be_encode
+            return result
+        return self.encoder(input, self.errors)[0]
+
+    def reset(self):
+        codecs.IncrementalEncoder.reset(self)
+        self.encoder = None
+
+class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
+    def __init__(self, errors='strict'):
+        codecs.BufferedIncrementalDecoder.__init__(self, errors)
+        self.decoder = None
+
+    def _buffer_decode(self, input, errors, final):
+        if self.decoder is None:
+            (output, consumed, byteorder) = \
+                codecs.utf_16_ex_decode(input, errors, 0, final)
+            if byteorder == -1:
+                self.decoder = codecs.utf_16_le_decode
+            elif byteorder == 1:
+                self.decoder = codecs.utf_16_be_decode
+            elif consumed >= 2:
+                raise UnicodeError("UTF-16 stream does not start with BOM")
+            return (output, consumed)
+        return self.decoder(input, self.errors, final)
+
+    def reset(self):
+        codecs.BufferedIncrementalDecoder.reset(self)
+        self.decoder = None
+
 class StreamWriter(codecs.StreamWriter):
     def __init__(self, stream, errors='strict'):
         self.bom_written = False
@@ -52,5 +93,12 @@ class StreamReader(codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (encode,decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='utf-16',
+        encode=encode,
+        decode=decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/encodings/utf_16_be.py b/Lib/encodings/utf_16_be.py
index 9a51f8c..86b458e 100644
--- a/Lib/encodings/utf_16_be.py
+++ b/Lib/encodings/utf_16_be.py
@@ -15,6 +15,13 @@ encode = codecs.utf_16_be_encode
 def decode(input, errors='strict'):
     return codecs.utf_16_be_decode(input, errors, True)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.utf_16_be_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
+    _buffer_decode = codecs.utf_16_be_decode
+
 class StreamWriter(codecs.StreamWriter):
     encode = codecs.utf_16_be_encode
 
@@ -24,5 +31,12 @@ class StreamReader(codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (encode,decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='utf-16-be',
+        encode=encode,
+        decode=decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/encodings/utf_16_le.py b/Lib/encodings/utf_16_le.py
index 95ca830..ec45414 100644
--- a/Lib/encodings/utf_16_le.py
+++ b/Lib/encodings/utf_16_le.py
@@ -15,15 +15,28 @@ encode = codecs.utf_16_le_encode
 def decode(input, errors='strict'):
     return codecs.utf_16_le_decode(input, errors, True)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.utf_16_le_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
+    _buffer_decode = codecs.utf_16_le_decode
+
 class StreamWriter(codecs.StreamWriter):
     encode = codecs.utf_16_le_encode
 
 class StreamReader(codecs.StreamReader):
     decode = codecs.utf_16_le_decode
 
-
 ### encodings module API
 
 def getregentry():
-
-    return (encode,decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='utf-16-le',
+        encode=encode,
+        decode=decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/encodings/utf_7.py b/Lib/encodings/utf_7.py
index ee78d09..7b11d59 100644
--- a/Lib/encodings/utf_7.py
+++ b/Lib/encodings/utf_7.py
@@ -13,6 +13,14 @@ class Codec(codecs.Codec):
     encode = codecs.utf_7_encode
     decode = codecs.utf_7_decode
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.utf_7_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
+    def _buffer_decode(self, input, errors, final):
+        return codecs.utf_7_decode(input, self.errors)
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -22,5 +30,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec.encode,Codec.decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='utf-7',
+        encode=Codec.encode,
+        decode=Codec.decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
\ No newline at end of file
diff --git a/Lib/encodings/utf_8.py b/Lib/encodings/utf_8.py
index 9cb0b4b..1bf6336 100644
--- a/Lib/encodings/utf_8.py
+++ b/Lib/encodings/utf_8.py
@@ -15,6 +15,13 @@ encode = codecs.utf_8_encode
 def decode(input, errors='strict'):
     return codecs.utf_8_decode(input, errors, True)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.utf_8_encode(input, self.errors)[0]
+
+class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
+    _buffer_decode = codecs.utf_8_decode
+
 class StreamWriter(codecs.StreamWriter):
     encode = codecs.utf_8_encode
 
@@ -24,5 +31,12 @@ class StreamReader(codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (encode,decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='utf-8',
+        encode=encode,
+        decode=decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/encodings/utf_8_sig.py b/Lib/encodings/utf_8_sig.py
index fa437e6..cd14ab0 100644
--- a/Lib/encodings/utf_8_sig.py
+++ b/Lib/encodings/utf_8_sig.py
@@ -22,6 +22,42 @@ def decode(input, errors='strict'):
     (output, consumed) = codecs.utf_8_decode(input, errors, True)
     return (output, consumed+prefix)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def __init__(self, errors='strict'):
+        codecs.IncrementalEncoder.__init__(self, errors)
+        self.first = True
+
+    def encode(self, input, final=False):
+        if self.first:
+            self.first = False
+            return codecs.BOM_UTF8 + codecs.utf_8_encode(input, errors)[0]
+        else:
+            return codecs.utf_8_encode(input, errors)[0]
+
+    def reset(self):
+        codecs.IncrementalEncoder.reset(self)
+        self.first = True
+
+class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
+    def __init__(self, errors='strict'):
+        codecs.BufferedIncrementalDecoder.__init__(self, errors)
+        self.first = True
+
+    def _buffer_decode(self, input, errors, final):
+        if self.first and codecs.BOM_UTF8.startswith(input): # might be a BOM
+            if len(input) < 3:
+                # not enough data to decide if this really is a BOM
+                # => try again on the next call
+                return (u"", 0)
+            (output, consumed) = codecs.utf_8_decode(input[3:], errors, final)
+            self.first = False
+            return (output, consumed+3)
+        return codecs.utf_8_decode(input, errors, final)
+
+    def reset(self):
+        codecs.BufferedIncrementalDecoder.reset(self)
+        self.first = True
+
 class StreamWriter(codecs.StreamWriter):
     def reset(self):
         codecs.StreamWriter.reset(self)
@@ -53,5 +89,12 @@ class StreamReader(codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (encode,decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='utf-8-sig',
+        encode=encode,
+        decode=decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/encodings/uu_codec.py b/Lib/encodings/uu_codec.py
index a70ff9e..0877fe1 100644
--- a/Lib/encodings/uu_codec.py
+++ b/Lib/encodings/uu_codec.py
@@ -96,9 +96,18 @@ class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
         return uu_encode(input,errors)
+
     def decode(self,input,errors='strict'):
         return uu_decode(input,errors)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return uu_encode(input, errors)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        return uu_decode(input, errors)[0]
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -108,5 +117,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (uu_encode,uu_decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='uu',
+        encode=uu_encode,
+        decode=uu_decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/encodings/zlib_codec.py b/Lib/encodings/zlib_codec.py
index 9b6e4d1..2694f15 100644
--- a/Lib/encodings/zlib_codec.py
+++ b/Lib/encodings/zlib_codec.py
@@ -50,6 +50,16 @@ class Codec(codecs.Codec):
     def decode(self, input, errors='strict'):
         return zlib_decode(input, errors)
 
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        assert self.errors == 'strict'
+        return zlib.compress(input)
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):
+        assert self.errors == 'strict'
+        return zlib.decompress(input)
+
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -59,5 +69,12 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (zlib_encode,zlib_decode,StreamReader,StreamWriter)
+    return codecs.CodecInfo(
+        name='zlib',
+        encode=zlib_encode,
+        decode=zlib_decode,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+        streamreader=StreamReader,
+        streamwriter=StreamWriter,
+    )
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 3944d65..913aa91 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -41,6 +41,33 @@ class ReadTest(unittest.TestCase):
         self.assertEqual(r.bytebuffer, "")
         self.assertEqual(r.charbuffer, u"")
 
+        # do the check again, this time using a incremental decoder
+        d = codecs.getincrementaldecoder(self.encoding)()
+        result = u""
+        for (c, partialresult) in zip(input.encode(self.encoding), partialresults):
+            result += d.decode(c)
+            self.assertEqual(result, partialresult)
+        # check that there's nothing left in the buffers
+        self.assertEqual(d.decode("", True), u"")
+        self.assertEqual(d.buffer, "")
+
+        # Check whether the rest method works properly
+        d.reset()
+        result = u""
+        for (c, partialresult) in zip(input.encode(self.encoding), partialresults):
+            result += d.decode(c)
+            self.assertEqual(result, partialresult)
+        # check that there's nothing left in the buffers
+        self.assertEqual(d.decode("", True), u"")
+        self.assertEqual(d.buffer, "")
+
+        # check iterdecode()
+        encoded = input.encode(self.encoding)
+        self.assertEqual(
+            input,
+            u"".join(codecs.iterdecode(encoded, self.encoding))
+        )
+
     def test_readline(self):
         def getreader(input):
             stream = StringIO.StringIO(input.encode(self.encoding))
@@ -977,6 +1004,12 @@ class BasicUnicodeTest(unittest.TestCase):
     def test_basics(self):
         s = u"abc123" # all codecs should be able to encode these
         for encoding in all_unicode_encodings:
+            name = codecs.lookup(encoding).name
+            if encoding.endswith("_codec"):
+                name += "_codec"
+            elif encoding == "latin_1":
+                name = "latin_1"
+            self.assertEqual(encoding.replace("_", "-"), name.replace("_", "-"))
             (bytes, size) = codecs.getencoder(encoding)(s)
             if encoding != "unicode_internal":
                 self.assertEqual(size, len(s), "%r != %r (encoding=%r)" % (size, len(s), encoding))
@@ -999,6 +1032,30 @@ class BasicUnicodeTest(unittest.TestCase):
                     decodedresult += reader.read()
                 self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
 
+                # check incremental decoder/encoder and iterencode()/iterdecode()
+                try:
+                    encoder = codecs.getincrementalencoder(encoding)()
+                except LookupError: # no IncrementalEncoder
+                    pass
+                else:
+                    # check incremental decoder/encoder
+                    encodedresult = ""
+                    for c in s:
+                        encodedresult += encoder.encode(c)
+                    decoder = codecs.getincrementaldecoder(encoding)()
+                    decodedresult = u""
+                    for c in encodedresult:
+                        decodedresult += decoder.decode(c)
+                    self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
+
+                    # check iterencode()/iterdecode()
+                    result = u"".join(codecs.iterdecode(codecs.iterencode(s, encoding), encoding))
+                    self.assertEqual(result, s, "%r != %r (encoding=%r)" % (result, s, encoding))
+
+                    # check iterencode()/iterdecode() with empty string
+                    result = u"".join(codecs.iterdecode(codecs.iterencode(u"", encoding), encoding))
+                    self.assertEqual(result, u"")
+
     def test_seek(self):
         # all codecs should be able to encode these
         s = u"%s\n%s\n" % (100*u"abc123", 100*u"def456")
diff --git a/Misc/NEWS b/Misc/NEWS
index 1c142fb..47da68c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -443,6 +443,12 @@ Extension Modules
 Library
 -------
 
+- Patch #1436130: codecs.lookup() now returns a CodecInfo object (a subclass
+  of tuple) that provides incremental decoders and encoders (a way to use
+  stateful codecs without the stream API). Functions
+  codecs.getincrementaldecoder() and codecs.getincrementalencoder() have
+  been added.
+
 - A regrtest option -w was added to re-run failed tests in verbose mode.
 
 - Patch #1446372: quit and exit can now be called from the interactive
diff --git a/Python/codecs.c b/Python/codecs.c
index 253bc39..0e8c374 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -260,6 +260,56 @@ PyObject *PyCodec_Decoder(const char *encoding)
     return NULL;
 }
 
+PyObject *PyCodec_IncrementalEncoder(const char *encoding,
+				     const char *errors)
+{
+    PyObject *codecs, *ret, *encoder;
+
+    codecs = _PyCodec_Lookup(encoding);
+    if (codecs == NULL)
+	goto onError;
+    encoder = PyObject_GetAttrString(codecs, "incrementalencoder");
+    if (encoder == NULL) {
+	Py_DECREF(codecs);
+	return NULL;
+    }
+    if (errors)
+	ret = PyObject_CallFunction(encoder, "O", errors);
+    else
+	ret = PyObject_CallFunction(encoder, NULL);
+    Py_DECREF(encoder);
+    Py_DECREF(codecs);
+    return ret;
+
+ onError:
+    return NULL;
+}
+
+PyObject *PyCodec_IncrementalDecoder(const char *encoding,
+				     const char *errors)
+{
+    PyObject *codecs, *ret, *decoder;
+
+    codecs = _PyCodec_Lookup(encoding);
+    if (codecs == NULL)
+	goto onError;
+    decoder = PyObject_GetAttrString(codecs, "incrementaldecoder");
+    if (decoder == NULL) {
+	Py_DECREF(codecs);
+	return NULL;
+    }
+    if (errors)
+	ret = PyObject_CallFunction(decoder, "O", errors);
+    else
+	ret = PyObject_CallFunction(decoder, NULL);
+    Py_DECREF(decoder);
+    Py_DECREF(codecs);
+    return ret;
+
+ onError:
+    return NULL;
+}
+
 PyObject *PyCodec_StreamReader(const char *encoding,
 			       PyObject *stream,
 			       const char *errors)
diff --git a/Tools/unicode/Makefile b/Tools/unicode/Makefile
index 34a9df9..f266d4d 100644
--- a/Tools/unicode/Makefile
+++ b/Tools/unicode/Makefile
@@ -44,11 +44,11 @@ windows:	build/
 	$(RM) -f build/readme.*
 
 iso:	build/
-	$(PYTHON) gencodec.py MAPPINGS/ISO8859/ build/iso
+	$(PYTHON) gencodec.py MAPPINGS/ISO8859/ build/ iso
 	$(RM) -f build/isoreadme.*
 
 apple:	build/
-	$(PYTHON) gencodec.py MAPPINGS/VENDORS/APPLE/ build/mac_
+	$(PYTHON) gencodec.py MAPPINGS/VENDORS/APPLE/ build/ mac_
 	$(RM) build/mac_dingbats.*
 	$(RM) build/mac_japanese.*
 	$(RM) build/mac_chin*
diff --git a/Tools/unicode/gencodec.py b/Tools/unicode/gencodec.py
index 9b4ae16..a31475e 100644
--- a/Tools/unicode/gencodec.py
+++ b/Tools/unicode/gencodec.py
@@ -248,7 +248,7 @@ def python_tabledef_code(varname, map, comments=1, key_precision=2):
     append(')')
     return l
 
-def codegen(name, map, comments=1):
+def codegen(name, map, encodingname, comments=1):
 
     """ Returns Python source for the given map.
 
@@ -272,7 +272,7 @@ def codegen(name, map, comments=1):
 
     l = [
         '''\
-""" Python Character Mapping Codec generated from '%s' with gencodec.py.
+""" Python Character Mapping Codec %s generated from '%s' with gencodec.py.
 
 """#"
 
@@ -283,11 +283,9 @@ import codecs
 class Codec(codecs.Codec):
 
     def encode(self,input,errors='strict'):
-
         return codecs.charmap_encode(input,errors,encoding_map)
 
-    def decode(self,input,errors='strict'):
-''' % name
+    def decode(self,input,errors='strict'):''' % (encodingname, name)
         ]
     if decoding_table_code:
         l.append('''\
@@ -297,6 +295,20 @@ class Codec(codecs.Codec):
         return codecs.charmap_decode(input,errors,decoding_map)''')
 
     l.append('''
+class IncrementalEncoder(codecs.IncrementalEncoder):
+    def encode(self, input, final=False):
+        return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+
+class IncrementalDecoder(codecs.IncrementalDecoder):
+    def decode(self, input, final=False):''')
+    if decoding_table_code:
+        l.append('''\
+        return codecs.charmap_decode(input,self.errors,decoding_table)[0]''')
+    else:
+        l.append('''\
+        return codecs.charmap_decode(input,self.errors,decoding_map)[0]''')
+
+    l.append('''
 class StreamWriter(Codec,codecs.StreamWriter):
     pass
 
@@ -306,9 +318,16 @@ class StreamReader(Codec,codecs.StreamReader):
 ### encodings module API
 
 def getregentry():
-
-    return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
-''')
+    return codecs.CodecInfo((
+        name=%r,
+        Codec().encode,
+        Codec().decode,
+        streamwriter=StreamWriter,
+        streamreader=StreamReader,
+        incrementalencoder=IncrementalEncoder,
+        incrementaldecoder=IncrementalDecoder,
+    ))
+''' % encodingname.replace('_', '-'))
 
     # Add decoding table or map (with preference to the table)
     if not decoding_table_code:
@@ -331,11 +350,11 @@ def getregentry():
     # Final new-line
     l.append('\n')
 
-    return '\n'.join(l)
+    return '\n'.join(l).expandtabs()
 
-def pymap(name,map,pyfile,comments=1):
+def pymap(name,map,pyfile,encodingname,comments=1):
 
-    code = codegen(name,map,comments)
+    code = codegen(name,map,encodingname,comments)
     f = open(pyfile,'w')
     f.write(code)
     f.close()
@@ -349,7 +368,7 @@ def marshalmap(name,map,marshalfile):
     marshal.dump(d,f)
     f.close()
 
-def convertdir(dir,prefix='',comments=1):
+def convertdir(dir, dirprefix='', nameprefix='', comments=1):
 
     mapnames = os.listdir(dir)
     for mapname in mapnames:
@@ -360,38 +379,40 @@ def convertdir(dir,prefix='',comments=1):
         name = name.replace('-','_')
         name = name.split('.')[0]
         name = name.lower()
+        name = nameprefix + name
         codefile = name + '.py'
         marshalfile = name + '.mapping'
         print 'converting %s to %s and %s' % (mapname,
-                                              prefix + codefile,
-                                              prefix + marshalfile)
+                                              dirprefix + codefile,
+                                              dirprefix + marshalfile)
         try:
             map = readmap(os.path.join(dir,mapname))
             if not map:
                 print '* map is empty; skipping'
             else:
-                pymap(mappathname, map, prefix + codefile,comments)
-                marshalmap(mappathname, map, prefix + marshalfile)
+                pymap(mappathname, map, dirprefix + codefile,name,comments)
+                marshalmap(mappathname, map, dirprefix + marshalfile)
         except ValueError, why:
             print '* conversion failed: %s' % why
             raise
 
-def rewritepythondir(dir,prefix='',comments=1):
+def rewritepythondir(dir, dirprefix='', comments=1):
 
     mapnames = os.listdir(dir)
     for mapname in mapnames:
         if not mapname.endswith('.mapping'):
             continue
-        codefile = mapname[:-len('.mapping')] + '.py'
+        name = mapname[:-len('.mapping')]
+        codefile = name + '.py'
         print 'converting %s to %s' % (mapname,
-                                       prefix + codefile)
+                                       dirprefix + codefile)
         try:
             map = marshal.load(open(os.path.join(dir,mapname),
                                'rb'))
             if not map:
                 print '* map is empty; skipping'
             else:
-                pymap(mapname, map, prefix + codefile,comments)
+                pymap(mapname, map, dirprefix + codefile,name,comments)
         except ValueError, why:
             print '* conversion failed: %s' % why
 
-- 
cgit v0.12

