[Python-checkins] r43045 - in python/trunk: Doc/lib/libcodecs.tex Include/codecs.h Lib/codecs.py Lib/encodings/__init__.py Lib/encodings/ascii.py Lib/encodings/base64_codec.py Lib/encodings/bz2_codec.py Lib/encodings/charmap.py Lib/encodings/cp03
Walter Dörwald
walter at livinglogic.de
Thu Mar 16 10:27:25 CET 2006
Neal Norwitz wrote:
> [...]
> In Python/codecs.c, I have a couple of questions. The code is at the
> bottom of the message.
>
> 1) PyObject_CallFunction(encoder, "O", errors); doesn't look correct.
> errors is a const char *, not a PyObject*. Shouldn't the "O" be "s"?
You're right!
> If it should, that probably means there are no tests with errors set,
> can you add tests for this condition?
Until a few days ago, I didn't know that it's possible to test
functionality that is only available from C!
I'll add tests to _testcapi.c
> 2) It looks like this code is duplicated except for the string passed
> to PyObject_GetAttrString(). Can you write a helper function and pass
> in the string? That would cut the code in half.
OK. The same can be done with PyCodec_Encoder()/PyCodec_Decoder() and
PyCodec_StreamWriter()/PyCodec_StreamReader().
> 3) Is the onError label necessary? It looks like it's only used in
> one place and the code might be easier to follow if you changed the
> goto to a return NULL;
Will do!
Bye,
Walter Dörwald
More information about the Python-checkins
mailing list