mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
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.
This commit is contained in:
parent
342c65e19a
commit
ef8b654bbe
7 changed files with 197 additions and 56 deletions
|
@ -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;
|
||||
|
|
|
@ -698,7 +698,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
|
|||
's' (recode all objects via Unicode) or
|
||||
't' (only recode non-string objects)
|
||||
*/
|
||||
if (*format != 's')
|
||||
if (*format == 's')
|
||||
recode_strings = 1;
|
||||
else if (*format == 't')
|
||||
recode_strings = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue