summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sre.c9
-rw-r--r--Modules/posixmodule.c3
2 files changed, 11 insertions, 1 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 1868657..f4cd1fe 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1674,6 +1674,15 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize)
void* ptr;
Py_buffer view;
+ /* Unicode objects do not support the buffer API. So, get the data
+ directly instead. */
+ if (PyUnicode_Check(string)) {
+ ptr = (void *)PyUnicode_AS_DATA(string);
+ *p_length = PyUnicode_GET_SIZE(string);
+ *p_charsize = sizeof(Py_UNICODE);
+ return ptr;
+ }
+
/* get pointer to string buffer */
view.len = -1;
buffer = Py_Type(string)->tp_as_buffer;
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 75ce991..2fe2b63 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2135,7 +2135,8 @@ posix_listdir(PyObject *self, PyObject *args)
FILEFINDBUF3 ep;
APIRET rc;
- if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len))
+ if (!PyArg_ParseTuple(args, "et#:listdir",
+ Py_FileSystemDefaultEncoding, &name, &len))
return NULL;
if (len >= MAX_PATH) {
PyErr_SetString(PyExc_ValueError, "path too long");