[Libguestfs] [PATCH 0/2] python: improved UTF8 decoding error handling

Matteo Cafasso noxdafox at gmail.com
Sun May 21 16:29:01 UTC 2017


The Python 3 bindings currently are unable to deal with non UTF8 characters.
This series continues what proposed in RHBZ#1406906.

A new function 'set_decode_error_handler' allows the User to specify
how to deal with decoding errors.

The default behaviour will be raising a UnicodeDecodeError.
If the handler is changed to 'surrogateescape', non UTF8 characters will be escaped
in a similar manner as for Python 2.

See PEP383 for reference.

This series fixes also a bug introduced in commit 9d25b4e56471f9c33ea6229a8b620fc800c240f8.

Matteo Cafasso (2):
  python: return bytes when return value is RBufferOut
  python: unicode decode handler error scheme setter

 generator/python.ml            | 19 ++++++++++++++++++-
 python/handle.c                | 28 ++++++++++++++++++++++++++--
 python/t/test830RHBZ1406906.py |  6 ++++++
 3 files changed, 50 insertions(+), 3 deletions(-)

--
2.11.0




More information about the Libguestfs mailing list