Commits

Anonymous committed 3351f94 Draft

Convert the object repr to unicode if required.

Comments (0)

Files changed (1)

inotify/_inotify.c

 	if (evt->name != Py_None) {
 		PyObject *pyname = PyObject_Repr(evt->name);
 
+#if PY_VERSION_HEX < 0x03000000
+		if (pyname != NULL && !PyUnicode_Check(pyname)) {
+			PyObject *unicode_pyname = PyObject_Unicode(pyname);
+			Py_XDECREF(pyname);
+			pyname = unicode_pyname;
+		} 
+#endif
 		if (cookie == 0)
 			ret = PyUnicode_FromFormat("event(wd=%d, mask=%U, name=%V)",
 										wd, pymask, pyname, "???");