Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2713be

Browse files
committed
Build with --disable-unicode again. Fixes #1158607.
Will backport to 2.4.
1 parent b60ae99 commit e2713be

7 files changed

Lines changed: 41 additions & 14 deletions

File tree

Lib/codecs.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,19 @@ def make_encoding_map(decoding_map):
720720

721721
### error handlers
722722

723-
strict_errors = lookup_error("strict")
724-
ignore_errors = lookup_error("ignore")
725-
replace_errors = lookup_error("replace")
726-
xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace")
727-
backslashreplace_errors = lookup_error("backslashreplace")
723+
try:
724+
strict_errors = lookup_error("strict")
725+
ignore_errors = lookup_error("ignore")
726+
replace_errors = lookup_error("replace")
727+
xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace")
728+
backslashreplace_errors = lookup_error("backslashreplace")
729+
except LookupError:
730+
# In --disable-unicode builds, these error handler are missing
731+
strict_errors = None
732+
ignore_errors = None
733+
replace_errors = None
734+
xmlcharrefreplace_errors = None
735+
backslashreplace_errors = None
728736

729737
# Tell modulefinder that using codecs probably needs the encodings
730738
# package

Lib/copy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ def _deepcopy_atomic(x, memo):
202202
d[bool] = _deepcopy_atomic
203203
try:
204204
d[complex] = _deepcopy_atomic
205-
except AttributeError:
205+
except NameError:
206206
pass
207207
d[str] = _deepcopy_atomic
208208
try:
209209
d[unicode] = _deepcopy_atomic
210-
except AttributeError:
210+
except NameError:
211211
pass
212212
try:
213213
d[types.CodeType] = _deepcopy_atomic

Lib/test/test_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def fcmp(x, y): # fuzzy comparison function
144144
TESTFN_UNICODE_UNENCODEABLE = None
145145
else:
146146
# Japanese characters (I think - from bug 846133)
147-
TESTFN_UNICODE_UNENCODEABLE = u"@test-\u5171\u6709\u3055\u308c\u308b"
147+
TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"')
148148
try:
149149
# XXX - Note - should be using TESTFN_ENCODING here - but for
150150
# Windows, "mbcs" currently always operates as if in

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Library
221221
Build
222222
-----
223223

224+
- Bug #1158607: Build with --disable-unicode again.
225+
224226
- spwdmodule.c is built only if either HAVE_GETSPNAM or HAVE_HAVE_GETSPENT is
225227
defined. Discovered as a result of not being able to build on OS X.
226228

Modules/_codecsmodule.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,15 @@ codec_encode(PyObject *self, PyObject *args)
104104
if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
105105
return NULL;
106106

107+
#ifdef Py_USING_UNICODE
107108
if (encoding == NULL)
108109
encoding = PyUnicode_GetDefaultEncoding();
110+
#else
111+
if (encoding == NULL) {
112+
PyErr_SetString(PyExc_ValueError, "no encoding specified");
113+
return NULL;
114+
}
115+
#endif
109116

110117
/* Encode via the codec registry */
111118
v = PyCodec_Encode(v, encoding, errors);
@@ -137,8 +144,15 @@ codec_decode(PyObject *self, PyObject *args)
137144
if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
138145
return NULL;
139146

147+
#ifdef Py_USING_UNICODE
140148
if (encoding == NULL)
141149
encoding = PyUnicode_GetDefaultEncoding();
150+
#else
151+
if (encoding == NULL) {
152+
PyErr_SetString(PyExc_ValueError, "no encoding specified");
153+
return NULL;
154+
}
155+
#endif
142156

143157
/* Decode via the codec registry */
144158
v = PyCodec_Decode(v, encoding, errors);

Modules/_tkinter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,10 @@ static PyGetSetDef PyTclObject_getsetlist[] = {
838838
};
839839

840840
static PyMethodDef PyTclObject_methods[] = {
841+
#ifdef Py_USING_UNICODE
841842
{"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS,
842843
PyTclObject_unicode__doc__},
844+
#endif
843845
{0}
844846
};
845847

@@ -991,7 +993,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
991993
}
992994
}
993995
#else
994-
res = PyString_FromStringAndSize(value->bytes, value->length);
996+
result = PyString_FromStringAndSize(value->bytes, value->length);
995997
#endif
996998
return result;
997999
}

setup.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,12 @@ class db_found(Exception): pass
799799
))
800800

801801
# Hye-Shik Chang's CJKCodecs modules.
802-
exts.append(Extension('_multibytecodec',
803-
['cjkcodecs/multibytecodec.c']))
804-
for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
805-
exts.append(Extension('_codecs_' + loc,
806-
['cjkcodecs/_codecs_%s.c' % loc]))
802+
if have_unicode:
803+
exts.append(Extension('_multibytecodec',
804+
['cjkcodecs/multibytecodec.c']))
805+
for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
806+
exts.append(Extension('_codecs_' + loc,
807+
['cjkcodecs/_codecs_%s.c' % loc]))
807808

808809
# Dynamic loading module
809810
if sys.maxint == 0x7fffffff:

0 commit comments

Comments
 (0)