diff options
author | Just van Rossum <just@letterror.com> | 2003-02-10 09:22:01 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2003-02-10 09:22:01 (GMT) |
commit | b9b8e9cf6d0d9b5d4d526f8cbd0601e284397753 (patch) | |
tree | f78ddb30a742100fa2d8468106ba48847801b00f /Python/bltinmodule.c | |
parent | 3aaf42c6139ed211a59b200130d1d205982b9818 (diff) | |
download | cpython-b9b8e9cf6d0d9b5d4d526f8cbd0601e284397753.zip cpython-b9b8e9cf6d0d9b5d4d526f8cbd0601e284397753.tar.gz cpython-b9b8e9cf6d0d9b5d4d526f8cbd0601e284397753.tar.bz2 |
My previous checkin caused compile() to no longer accept buffers, as noted
my MAL. Fixed. (Btw. eval() still doesn't take buffers, but that was so
even before my patch.)
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 9b1bf55..0b43905 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -18,6 +18,8 @@ */ #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) const char *Py_FileSystemDefaultEncoding = "mbcs"; +#elif defined(__APPLE__) +const char *Py_FileSystemDefaultEncoding = "utf-8"; #else const char *Py_FileSystemDefaultEncoding = NULL; /* use default */ #endif @@ -341,6 +343,7 @@ builtin_compile(PyObject *self, PyObject *args) int supplied_flags = 0; PyCompilerFlags cf; PyObject *result, *cmd, *tmp = NULL; + int length; if (!PyArg_ParseTuple(args, "Oss|ii:compile", &cmd, &filename, &startstr, &supplied_flags, &dont_inherit)) @@ -357,15 +360,14 @@ builtin_compile(PyObject *self, PyObject *args) cf.cf_flags |= PyCF_SOURCE_IS_UTF8; } #endif - if (!PyString_Check(cmd)) { + if (PyObject_AsReadBuffer(cmd, (const void **)&str, &length)) + return NULL; + if (length != strlen(str)) { PyErr_SetString(PyExc_TypeError, - "compile() arg 1 must be a string"); + "expected string without null bytes"); return NULL; } - if (PyString_AsStringAndSize(cmd, &str, NULL)) - return NULL; - if (strcmp(startstr, "exec") == 0) start = Py_file_input; else if (strcmp(startstr, "eval") == 0) |