summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2000-08-03 18:46:08 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2000-08-03 18:46:08 (GMT)
commitbff879cabba567f1c57ae41c3c69bb1ac275860a (patch)
treef77dca0c907d47543bfe2d4acf40685d5e3c24ef /Python/getargs.c
parent2b83b4601f9f588b46667b541b100b5924019a14 (diff)
downloadcpython-bff879cabba567f1c57ae41c3c69bb1ac275860a.zip
cpython-bff879cabba567f1c57ae41c3c69bb1ac275860a.tar.gz
cpython-bff879cabba567f1c57ae41c3c69bb1ac275860a.tar.bz2
This patch finalizes the move from UTF-8 to a default encoding in
the Python Unicode implementation. The internal buffer used for implementing the buffer protocol is renamed to defenc to make this change visible. It now holds the default encoded version of the Unicode object and is calculated on demand (NULL otherwise). Since the default encoding defaults to ASCII, this will mean that Unicode objects which hold non-ASCII characters will no longer work on C APIs using the "s" or "t" parser markers. C APIs must now explicitly provide Unicode support via the "u", "U" or "es"/"es#" parser markers in order to work with non-ASCII Unicode strings. (Note: this patch will also have to be applied to the 1.6 branch of the CVS tree.)
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index f1835ba..ceaf6cb 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -372,7 +372,7 @@ convertsimple(PyObject *arg, char **p_format, va_list *p_va, char *msgbuf)
/* Internal API needed by convertsimple1(): */
extern
-PyObject *_PyUnicode_AsUTF8String(PyObject *unicode,
+PyObject *_PyUnicode_AsDefaultEncodedString(PyObject *unicode,
const char *errors);
/* Convert a non-tuple argument. Return NULL if conversion went OK,
@@ -567,7 +567,8 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
if (PyString_Check(arg))
*p = PyString_AS_STRING(arg);
else if (PyUnicode_Check(arg)) {
- arg = _PyUnicode_AsUTF8String(arg, NULL);
+ arg = _PyUnicode_AsDefaultEncodedString(
+ arg, NULL);
if (arg == NULL)
return "unicode conversion error";
*p = PyString_AS_STRING(arg);
@@ -612,7 +613,8 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
else if (PyString_Check(arg))
*p = PyString_AsString(arg);
else if (PyUnicode_Check(arg)) {
- arg = _PyUnicode_AsUTF8String(arg, NULL);
+ arg = _PyUnicode_AsDefaultEncodedString(
+ arg, NULL);
if (arg == NULL)
return "unicode conversion error";
*p = PyString_AS_STRING(arg);
@@ -644,7 +646,7 @@ convertsimple1(PyObject *arg, char **p_format, va_list *p_va)
/* Get 'e' parameter: the encoding name */
encoding = (const char *)va_arg(*p_va, const char *);
if (encoding == NULL)
- return "(encoding is NULL)";
+ encoding = PyUnicode_GetDefaultEncoding();
/* Get 's' parameter: the output buffer to use */
if (*format != 's')