summaryrefslogtreecommitdiffstats
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-03-08 15:03:08 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2005-03-08 15:03:08 (GMT)
commite2713becd8cb0c3b2db4d33832dd57a1d619f0f3 (patch)
treec46d31f73c95c9a969b6704719dac3e83eb435f1 /Modules/_codecsmodule.c
parentb60ae9960182b8eecb26da12171917ee5a6cc1fc (diff)
downloadcpython-e2713becd8cb0c3b2db4d33832dd57a1d619f0f3.zip
cpython-e2713becd8cb0c3b2db4d33832dd57a1d619f0f3.tar.gz
cpython-e2713becd8cb0c3b2db4d33832dd57a1d619f0f3.tar.bz2
Build with --disable-unicode again. Fixes #1158607.
Will backport to 2.4.
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index ccad827..a6c42b1 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -104,8 +104,15 @@ codec_encode(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
return NULL;
+#ifdef Py_USING_UNICODE
if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();
+#else
+ if (encoding == NULL) {
+ PyErr_SetString(PyExc_ValueError, "no encoding specified");
+ return NULL;
+ }
+#endif
/* Encode via the codec registry */
v = PyCodec_Encode(v, encoding, errors);
@@ -137,8 +144,15 @@ codec_decode(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
return NULL;
+#ifdef Py_USING_UNICODE
if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();
+#else
+ if (encoding == NULL) {
+ PyErr_SetString(PyExc_ValueError, "no encoding specified");
+ return NULL;
+ }
+#endif
/* Decode via the codec registry */
v = PyCodec_Decode(v, encoding, errors);