[XML-SIG] Encoding argument for toxml and toprettyxml

Martin v. Loewis martin@v.loewis.de
03 Jul 2002 08:30:03 +0200


Walter D=F6rwald <walter@livinglogic.de> writes:

> Currently I can't imagine a stream writer where the state menagement
> depends on the error handling name. Can you give an example?=20

No, I can't. I know that encoders have to be stateful, but I can't
give a real-world example where the state needs to take into account
error handling.

> But this only checks if the error handling API is present in
> Python. It does not check whether a certain codec uses the API.

Using that as a check for "Python 2.3" is good enough for me.

> How about the following code? This will raise the same exception
> if assigning the errors attribute or using it doesn't work:
>=20
> try:
>     try:
>        writer.errors =3D errors
>     except AttributeError:
>        pass
>      writer.write(data)
> except ValueError:
>      try:
>        writer.errors =3D "strict"
>     except AttributeError:
>        pass
>      writer.write(data)

I don't think that can work. What if the first write was "partial",
i.e. already wrote some of the data?

Regards,
Martin