When I run this Python 2.7 code (edit: updated the code)
import io
x = io.StringIO(u'\ud801')
CPython runs fine, but IronPython throws the following error:
UnicodeEncodeError:
Unable to translate Unicode character \uD801 at index 0 to specified code page.
I presume this is because U+D801 is an unpaired surrogate and thus an invalid character, but which implementation is displaying correct behavior here? Should this code throw or not throw?