Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 17817:f7c385226f65 legacy-trunk
Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
| author | Mark Hammond <mhammond@skippinet.com.au> |
|---|---|
| date | Sun, 13 May 2001 08:04:26 +0000 |
| parents | aab6c1f19289 |
| children | 50376d470648 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Sun May 13 06:43:53 2001 +0000 +++ b/Python/bltinmodule.c Sun May 13 08:04:26 2001 +0000 @@ -13,6 +13,8 @@ #include <unistd.h> #endif +extern const char *Py_FileSystemDefaultEncoding; + /* Forward */ static PyObject *filterstring(PyObject *, PyObject *); static PyObject *filtertuple (PyObject *, PyObject *); @@ -1530,14 +1532,16 @@ static PyObject * builtin_open(PyObject *self, PyObject *args) { - char *name; + char *name = NULL; char *mode = "r"; int bufsize = -1; PyObject *f; - if (!PyArg_ParseTuple(args, "s|si:open", &name, &mode, &bufsize)) + if (!PyArg_ParseTuple(args, "et|si:open", Py_FileSystemDefaultEncoding, + &name, &mode, &bufsize)) return NULL; f = PyFile_FromString(name, mode); + PyMem_Free(name); /* free the encoded string */ if (f != NULL) PyFile_SetBufSize(f, bufsize); return f;
