Skip to content

Commit

Permalink
Ensure python2 examples passing unicode strings work
Browse files Browse the repository at this point in the history
e.g. Table1_utf8.py
     Label1_de.py
     Label1_ja.py

Signed-off-by: Noel Power <noel.power@suse.com>
  • Loading branch information
noelpower committed Feb 8, 2023
1 parent e635837 commit c021144
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ytypes.i
Expand Up @@ -26,7 +26,7 @@ YCPValue pyval_to_ycp(PyObject *input)
#if PY_MAJOR_VERSION >= 3
return YCPString(_PyUnicode_AsString(input));
#else
PyObject* encoded = PyUnicode_Encode(PyUnicode_AsUnicode(input), PyUnicode_GetSize(input), "ascii", NULL);
PyObject* encoded = PyUnicode_AsEncodedString(input, "utf8", NULL);
return YCPString(PyBytes_AsString(encoded));
#endif
}
Expand Down

0 comments on commit c021144

Please sign in to comment.