bodograumann / python-iconv

Python 3 wrapper for iconv and usage as codecs
GNU General Public License v3.0
7 stars 2 forks source link

#2: Handle buffer size and other errors properly #3

Closed nwoods closed 3 years ago

nwoods commented 3 years ago

This is my first time working on an implementation of the codec API so please be patient if I did anything stupid.

Changes:

When the buffer is too small, I increase it by 10% (min 3 bytes). I chose those numbers based on nothing whatsoever, and I'm open to other suggestions.

The unit tests succeed, and this works for my use cases plus some others I fiddled around with, but I wouldn't say it has been tested extensively.

nwoods commented 3 years ago

Edit: Factored implementations into separate functions to avoid unnecessary decode-encode during encoding retry when buffer is too small, and to avoid changing the interface of functions that should respect the codec API.