[Python-checkins] python/dist/src/Doc/lib libcodecs.tex,1.16,1.17 libfuncs.tex,1.127,1.128

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Fri, 31 Jan 2003 09:19:40 -0800


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv3391/dist/src/Doc/lib

Modified Files:
	libcodecs.tex libfuncs.tex 
Log Message:
Change the treatment of positions returned by PEP293
error handers in the Unicode codecs: Negative
positions are treated as being relative to the end of
the input and out of bounds positions result in an
IndexError.

Also update the PEP and include an explanation of
this in the documentation for codecs.register_error.

Fixes a small bug in iconv_codecs: if the position
from the callback is negative *add* it to the size
instead of substracting it.

>From SF patch #677429.


Index: libcodecs.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** libcodecs.tex	31 Dec 2002 12:39:07 -0000	1.16
--- libcodecs.tex	31 Jan 2003 17:19:04 -0000	1.17
***************
*** 104,112 ****
  name \var{name}. \var{error_handler} will be called during encoding
  and decoding in case of an error, when \var{name} is specified as the
! errors parameter. \var{error_handler} will be called with an
! \exception{UnicodeEncodeError}, \exception{UnicodeDecodeError} or
! \exception{UnicodeTranslateError} instance and must return a tuple
! with a replacement for the unencodable/undecodable part of the input
! and a position where encoding/decoding should continue.
  \end{funcdesc}
  
--- 104,123 ----
  name \var{name}. \var{error_handler} will be called during encoding
  and decoding in case of an error, when \var{name} is specified as the
! errors parameter.
! 
! For encoding \var{error_handler} will be called with a
! \exception{UnicodeEncodeError} instance, which contains information about
! the location of the error. The error handler must either raise this or
! a different exception or return a tuple with a replacement for the
! unencodable part of the input and a position where encoding should
! continue. The encoder will encode the replacement and continue encoding
! the original input at the specified position. Negative position values
! will be treated as being relative to the end of the input string. If the
! resulting position is out of bound an IndexError will be raised.
! 
! Decoding and translating works similar, except \exception{UnicodeDecodeError}
! or \exception{UnicodeTranslateError} will be passed to the handler and
! that the replacement from the error handler will be put into the output
! directly.
  \end{funcdesc}
  

Index: libfuncs.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v
retrieving revision 1.127
retrieving revision 1.128
diff -C2 -d -r1.127 -r1.128
*** libfuncs.tex	4 Jan 2003 02:16:22 -0000	1.127
--- libfuncs.tex	31 Jan 2003 17:19:05 -0000	1.128
***************
*** 573,577 ****
    thereof.  Also return true if \var{classinfo} is a type object and
    \var{object} is an object of that type.  If \var{object} is not a
!   class instance or a object of the given type, the function always
    returns false.  If \var{classinfo} is neither a class object nor a
    type object, it may be a tuple of class or type objects, or may
--- 573,577 ----
    thereof.  Also return true if \var{classinfo} is a type object and
    \var{object} is an object of that type.  If \var{object} is not a
!   class instance or an object of the given type, the function always
    returns false.  If \var{classinfo} is neither a class object nor a
    type object, it may be a tuple of class or type objects, or may