summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorMark Hammond <mhammond@skippinet.com.au>2001-05-13 08:04:26 (GMT)
committerMark Hammond <mhammond@skippinet.com.au>2001-05-13 08:04:26 (GMT)
commitef8b654bbea15dc55767a7095e01dff7a3ca86cb (patch)
tree778653b95245ae2d31e5a5ed94c0c491e1687b15 /Python/bltinmodule.c
parent342c65e19ac0cc47bf2b21026c76e63440b23748 (diff)
downloadcpython-ef8b654bbea15dc55767a7095e01dff7a3ca86cb.zip
cpython-ef8b654bbea15dc55767a7095e01dff7a3ca86cb.tar.gz
cpython-ef8b654bbea15dc55767a7095e01dff7a3ca86cb.tar.bz2
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.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index cc1bc95..5ffecb3 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -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 @@ Return the octal representation of an integer or long integer.";
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;