[Python-checkins] python/dist/src/Modules _iconv_codec.c,NONE,1.1

Walter Dörwald walter@livinglogic.de
Tue, 28 Jan 2003 12:30:33 +0100


Martin v. Löwis wrote:

> Walter Dörwald <walter@livinglogic.de> writes:
> 
>>This interprets negative indizes as being relative to the
>>end of the input. All other encoders treat <0 as ==0.
> 
> 
> Hmm. This appears to be unspecified in the PEP. What is the rationale
> for equating <0 to =0?

It just was the simplest solution.

> It appears that this indicates a bug in the
> error callback, which should not pass silently.

So would a position that is beyond the end of the input.

> In any case, I'ld like to request that the documentation is clarified
> in this aspect (preferable, the "proper" documentation, not (just) the
> PEP). Once that clarification is added, the incorrect codecs should be
> corrected.

So how should we handle these cases?

a) Treat negative positions as relative to the end
b) Treat negative positions as 0
c) Clip out of bounds positions to the length of the input
d) Raise an exception

I'd vote for a) + d)

If that's what we want to do I'll update the PEP, the documentation
and the implemenation.

Bye,
    Walter Dörwald