summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-10-15 13:25:28 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-10-15 13:25:28 (GMT)
commit7a6debe79c1aabe7686b60e19ad77055b874c2f4 (patch)
treefcc4baf7a7b387a8ef67f4b87b4d5f22b522c157
parentab7e2a4454a283cf1386c3d4690d77af9ef5189a (diff)
downloadcpython-7a6debe79c1aabe7686b60e19ad77055b874c2f4.zip
cpython-7a6debe79c1aabe7686b60e19ad77055b874c2f4.tar.gz
cpython-7a6debe79c1aabe7686b60e19ad77055b874c2f4.tar.bz2
remove some duplication
-rw-r--r--Objects/unicodeobject.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 2ca271f..5f56cf7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -2838,6 +2838,10 @@ normalize_encoding(const char *encoding,
char *l;
char *l_end;
+ if (encoding == NULL) {
+ strcpy(lower, "utf-8");
+ return 1;
+ }
e = encoding;
l = lower;
l_end = &lower[lower_len - 1];
@@ -2869,9 +2873,6 @@ PyUnicode_Decode(const char *s,
Py_buffer info;
char lower[11]; /* Enough for any encoding shortcut */
- if (encoding == NULL)
- return PyUnicode_DecodeUTF8(s, size, errors);
-
/* Shortcuts for common default encodings */
if (normalize_encoding(encoding, lower, sizeof(lower))) {
if ((strcmp(lower, "utf-8") == 0) ||
@@ -3101,13 +3102,6 @@ PyUnicode_AsEncodedString(PyObject *unicode,
return NULL;
}
- if (encoding == NULL) {
- if (errors == NULL || strcmp(errors, "strict") == 0)
- return _PyUnicode_AsUTF8String(unicode, NULL);
- else
- return _PyUnicode_AsUTF8String(unicode, errors);
- }
-
/* Shortcuts for common default encodings */
if (normalize_encoding(encoding, lower, sizeof(lower))) {
if ((strcmp(lower, "utf-8") == 0) ||