Skip to content

Commit 22b8dd1

Browse files
committed
When getting string size, count UTF8 bytes
.. rather than Unicode code points. Closes #77
1 parent e457b5f commit 22b8dd1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

fuseparts/_fusemodule.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,16 @@
9494
PyErr_SetString(PyExc_ValueError, "non-decodable filename");
9595
return NULL;
9696
}
97-
97+
static inline Py_ssize_t PyString_Size(PyObject *s) {
98+
Py_ssize_t result = -1;
99+
(void)PyUnicode_AsUTF8AndSize(s, &result);
100+
return result;
101+
}
98102
#else
99103
#define PyString_AsString PyUnicode_AsUTF8
104+
#define PyString_Size PyUnicode_GET_LENGTH
100105
#endif
101106
#define PyString_Check PyUnicode_Check
102-
#define PyString_Size PyUnicode_GET_LENGTH
103107
#endif
104108

105109
#ifdef FIX_PATH_DECODING

0 commit comments

Comments
 (0)