Fix segfault on error in PyUnicode_AsEncodedString