Skip to content

Commit 8d30cc0

Browse files
committed
Get rid of all #ifdef Py_USING_UNICODE (it is always present now).
(With the help of unifdef from freshmeat.)
1 parent 938ef57 commit 8d30cc0

36 files changed

+10
-472
lines changed

Include/longobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
5151
#endif /* HAVE_LONG_LONG */
5252

5353
PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
54-
#ifdef Py_USING_UNICODE
5554
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
56-
#endif
5755

5856
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
5957
v must not be NULL, and must be a normalized long.

Include/object.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,7 @@ PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
374374
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
375375
PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *);
376376
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
377-
#ifdef Py_USING_UNICODE
378377
PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *);
379-
#endif
380378
PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
381379
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
382380
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);

Include/pyerrors.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ typedef struct {
2626
PyObject *print_file_and_line;
2727
} PySyntaxErrorObject;
2828

29-
#ifdef Py_USING_UNICODE
3029
typedef struct {
3130
PyObject_HEAD
3231
PyObject *dict;
@@ -38,7 +37,6 @@ typedef struct {
3837
PyObject *end;
3938
PyObject *reason;
4039
} PyUnicodeErrorObject;
41-
#endif
4240

4341
typedef struct {
4442
PyObject_HEAD
@@ -235,7 +233,6 @@ PyAPI_FUNC(void) PyErr_SetInterrupt(void);
235233
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
236234
PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
237235

238-
#ifdef Py_USING_UNICODE
239236
/* The following functions are used to create and modify unicode
240237
exceptions from C */
241238

@@ -297,7 +294,6 @@ PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
297294
PyObject *, const char *);
298295
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
299296
PyObject *, const char *);
300-
#endif
301297

302298

303299
/* These APIs aren't really part of the error implementation, but

Include/unicodeobject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ Copyright (c) Corporation for National Research Initiatives.
5858

5959
/* --- Internal Unicode Format -------------------------------------------- */
6060

61-
#ifndef Py_USING_UNICODE
62-
63-
#define PyUnicode_Check(op) 0
64-
#define PyUnicode_CheckExact(op) 0
65-
66-
#else
67-
6861
/* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is
6962
properly set, but the default rules below doesn't set it. I'll
7063
sort this out some other day -- [email protected] */
@@ -1262,5 +1255,4 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
12621255
#ifdef __cplusplus
12631256
}
12641257
#endif
1265-
#endif /* Py_USING_UNICODE */
12661258
#endif /* !Py_UNICODEOBJECT_H */

Modules/_codecsmodule.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,8 @@ codec_encode(PyObject *self, PyObject *args)
9393
if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
9494
return NULL;
9595

96-
#ifdef Py_USING_UNICODE
9796
if (encoding == NULL)
9897
encoding = PyUnicode_GetDefaultEncoding();
99-
#else
100-
if (encoding == NULL) {
101-
PyErr_SetString(PyExc_ValueError, "no encoding specified");
102-
return NULL;
103-
}
104-
#endif
10598

10699
/* Encode via the codec registry */
107100
return PyCodec_Encode(v, encoding, errors);
@@ -127,15 +120,8 @@ codec_decode(PyObject *self, PyObject *args)
127120
if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
128121
return NULL;
129122

130-
#ifdef Py_USING_UNICODE
131123
if (encoding == NULL)
132124
encoding = PyUnicode_GetDefaultEncoding();
133-
#else
134-
if (encoding == NULL) {
135-
PyErr_SetString(PyExc_ValueError, "no encoding specified");
136-
return NULL;
137-
}
138-
#endif
139125

140126
/* Decode via the codec registry */
141127
return PyCodec_Decode(v, encoding, errors);
@@ -198,7 +184,6 @@ escape_encode(PyObject *self,
198184
return codec_tuple(str, PyString_Size(str));
199185
}
200186

201-
#ifdef Py_USING_UNICODE
202187
/* --- Decoder ------------------------------------------------------------ */
203188

204189
static PyObject *
@@ -833,7 +818,6 @@ mbcs_encode(PyObject *self,
833818
}
834819

835820
#endif /* MS_WINDOWS */
836-
#endif /* Py_USING_UNICODE */
837821

838822
/* --- Error handler registry --------------------------------------------- */
839823

@@ -888,7 +872,6 @@ static PyMethodDef _codecs_functions[] = {
888872
decode__doc__},
889873
{"escape_encode", escape_encode, METH_VARARGS},
890874
{"escape_decode", escape_decode, METH_VARARGS},
891-
#ifdef Py_USING_UNICODE
892875
{"utf_8_encode", utf_8_encode, METH_VARARGS},
893876
{"utf_8_decode", utf_8_decode, METH_VARARGS},
894877
{"utf_7_encode", utf_7_encode, METH_VARARGS},
@@ -919,7 +902,6 @@ static PyMethodDef _codecs_functions[] = {
919902
{"mbcs_encode", mbcs_encode, METH_VARARGS},
920903
{"mbcs_decode", mbcs_decode, METH_VARARGS},
921904
#endif
922-
#endif /* Py_USING_UNICODE */
923905
{"register_error", register_error, METH_VARARGS,
924906
register_error__doc__},
925907
{"lookup_error", lookup_error, METH_VARARGS,

Modules/_elementtree.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,6 @@ do { memory -= size; printf("%8d - %s\n", memory, comment); } while (0)
9393
#define LOCAL(type) static type
9494
#endif
9595

96-
/* compatibility macros */
97-
#if (PY_VERSION_HEX < 0x02050000)
98-
typedef int Py_ssize_t;
99-
#define lenfunc inquiry
100-
#endif
101-
102-
#if (PY_VERSION_HEX < 0x02040000)
103-
#define PyDict_CheckExact PyDict_Check
104-
#if (PY_VERSION_HEX < 0x02020000)
105-
#define PyList_CheckExact PyList_Check
106-
#define PyString_CheckExact PyString_Check
107-
#if (PY_VERSION_HEX >= 0x01060000)
108-
#define Py_USING_UNICODE /* always enabled for 2.0 and 2.1 */
109-
#endif
110-
#endif
111-
#endif
112-
113-
#if !defined(Py_RETURN_NONE)
114-
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
115-
#endif
116-
11796
/* macros used to store 'join' flags in string object pointers. note
11897
that all use of text and tail as object pointers must be wrapped in
11998
JOIN_OBJ. see comments in the ElementObject definition for more
@@ -724,7 +703,6 @@ checkpath(PyObject* tag)
724703

725704
#define PATHCHAR(ch) (ch == '/' || ch == '*' || ch == '[' || ch == '@')
726705

727-
#if defined(Py_USING_UNICODE)
728706
if (PyUnicode_Check(tag)) {
729707
Py_UNICODE *p = PyUnicode_AS_UNICODE(tag);
730708
for (i = 0; i < PyUnicode_GET_SIZE(tag); i++) {
@@ -737,7 +715,6 @@ checkpath(PyObject* tag)
737715
}
738716
return 0;
739717
}
740-
#endif
741718
if (PyString_Check(tag)) {
742719
char *p = PyString_AS_STRING(tag);
743720
for (i = 0; i < PyString_GET_SIZE(tag); i++) {
@@ -1860,7 +1837,6 @@ static PyTypeObject XMLParser_Type;
18601837

18611838
/* helpers */
18621839

1863-
#if defined(Py_USING_UNICODE)
18641840
LOCAL(int)
18651841
checkstring(const char* string, int size)
18661842
{
@@ -1873,18 +1849,15 @@ checkstring(const char* string, int size)
18731849

18741850
return 0;
18751851
}
1876-
#endif
18771852

18781853
LOCAL(PyObject*)
18791854
makestring(const char* string, int size)
18801855
{
18811856
/* convert a UTF-8 string to either a 7-bit ascii string or a
18821857
Unicode string */
18831858

1884-
#if defined(Py_USING_UNICODE)
18851859
if (checkstring(string, size))
18861860
return PyUnicode_DecodeUTF8(string, size, "strict");
1887-
#endif
18881861

18891862
return PyString_FromStringAndSize(string, size);
18901863
}
@@ -1934,7 +1907,6 @@ makeuniversal(XMLParserObject* self, const char* string)
19341907
}
19351908

19361909
/* decode universal name */
1937-
#if defined(Py_USING_UNICODE)
19381910
/* inline makestring, to avoid duplicating the source string if
19391911
it's not an utf-8 string */
19401912
p = PyString_AS_STRING(tag);
@@ -1946,7 +1918,6 @@ makeuniversal(XMLParserObject* self, const char* string)
19461918
return NULL;
19471919
}
19481920
} else
1949-
#endif
19501921
value = tag; /* use tag as is */
19511922

19521923
/* add to names dictionary */
@@ -2163,7 +2134,6 @@ expat_pi_handler(XMLParserObject* self, const XML_Char* target_in,
21632134
}
21642135
}
21652136

2166-
#if defined(Py_USING_UNICODE)
21672137
static int
21682138
expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
21692139
XML_Encoding *info)
@@ -2200,7 +2170,6 @@ expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
22002170

22012171
return XML_STATUS_OK;
22022172
}
2203-
#endif
22042173

22052174
/* -------------------------------------------------------------------- */
22062175
/* constructor and destructor */
@@ -2306,12 +2275,10 @@ xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
23062275
self->parser,
23072276
(XML_ProcessingInstructionHandler) expat_pi_handler
23082277
);
2309-
#if defined(Py_USING_UNICODE)
23102278
EXPAT(SetUnknownEncodingHandler)(
23112279
self->parser,
23122280
(XML_UnknownEncodingHandler) expat_unknown_encoding_handler, NULL
23132281
);
2314-
#endif
23152282

23162283
ALLOC(sizeof(XMLParserObject), "create expatparser");
23172284

Modules/_localemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ PyDoc_STRVAR(strcoll__doc__,
270270
static PyObject*
271271
PyLocale_strcoll(PyObject* self, PyObject* args)
272272
{
273-
#if !defined(HAVE_WCSCOLL) || !defined(Py_USING_UNICODE)
273+
#if !defined(HAVE_WCSCOLL)
274274
char *s1,*s2;
275275

276276
if (!PyArg_ParseTuple(args, "ss:strcoll", &s1, &s2))

Modules/_sre.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,8 @@ static char copyright[] =
5858
/* defining this one enables tracing */
5959
#undef VERBOSE
6060

61-
#if PY_VERSION_HEX >= 0x01060000
62-
#if PY_VERSION_HEX < 0x02020000 || defined(Py_USING_UNICODE)
6361
/* defining this enables unicode support (default under 1.6a1 and later) */
6462
#define HAVE_UNICODE
65-
#endif
66-
#endif
6763

6864
/* -------------------------------------------------------------------- */
6965
/* optional features */

Modules/_testcapimodule.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ test_k_code(PyObject *self)
456456
return Py_None;
457457
}
458458

459-
#ifdef Py_USING_UNICODE
460459

461460
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
462461
of an error.
@@ -518,7 +517,6 @@ codec_incrementaldecoder(PyObject *self, PyObject *args)
518517
return PyCodec_IncrementalDecoder(encoding, errors);
519518
}
520519

521-
#endif
522520

523521
/* Simple test of _PyLong_NumBits and _PyLong_Sign. */
524522
static PyObject *
@@ -863,9 +861,7 @@ static PyMethodDef TestMethods[] = {
863861
{"codec_incrementaldecoder",
864862
(PyCFunction)codec_incrementaldecoder, METH_VARARGS},
865863
#endif
866-
#ifdef Py_USING_UNICODE
867864
{"test_u_code", (PyCFunction)test_u_code, METH_NOARGS},
868-
#endif
869865
#ifdef WITH_THREAD
870866
{"_test_thread_state", test_thread_state, METH_VARARGS},
871867
#endif

0 commit comments

Comments
 (0)