Skip to content

Commit feb7307

Browse files
committed
python#9210: remove --with-wctype-functions configure option.
The internal unicode database is now always used. (after 5 years: see http://mail.python.org/pipermail/python-dev/2004-December/050193.html )
1 parent b2f9840 commit feb7307

9 files changed

Lines changed: 10 additions & 120 deletions

File tree

Doc/whatsnew/3.2.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ Changes to Python's build process and to the C API include:
525525

526526
(Contributed by Antoine Pitrou; :issue:`9203`.)
527527

528+
* The option ``--with-wctype-functions`` was removed. The built-in unicode
529+
database is now used for all functions.
530+
531+
(Contributed by Amaury Forgeot D'Arc; :issue:`9210`.)
532+
528533

529534
Porting to Python 3.2
530535
=====================

Include/unicodeobject.h

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Copyright (c) Corporation for National Research Initiatives.
7878
#define Py_UNICODE_WIDE
7979
#endif
8080

81-
/* Set these flags if the platform has "wchar.h", "wctype.h" and the
81+
/* Set these flags if the platform has "wchar.h" and the
8282
wchar_t type is a 16-bit unsigned type */
8383
/* #define HAVE_WCHAR_H */
8484
/* #define HAVE_USABLE_WCHAR_T */
@@ -309,39 +309,6 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
309309

310310
/* --- Internal Unicode Operations ---------------------------------------- */
311311

312-
/* If you want Python to use the compiler's wctype.h functions instead
313-
of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or
314-
configure Python using --with-wctype-functions. This reduces the
315-
interpreter's code size. */
316-
317-
#if defined(Py_UNICODE_WIDE) && defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS)
318-
319-
#include <wctype.h>
320-
321-
#define Py_UNICODE_ISSPACE(ch) iswspace(ch)
322-
323-
#define Py_UNICODE_ISLOWER(ch) iswlower(ch)
324-
#define Py_UNICODE_ISUPPER(ch) iswupper(ch)
325-
#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch)
326-
#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch)
327-
328-
#define Py_UNICODE_TOLOWER(ch) towlower(ch)
329-
#define Py_UNICODE_TOUPPER(ch) towupper(ch)
330-
#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch)
331-
332-
#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch)
333-
#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch)
334-
#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch)
335-
#define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch)
336-
337-
#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch)
338-
#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch)
339-
#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch)
340-
341-
#define Py_UNICODE_ISALPHA(ch) iswalpha(ch)
342-
343-
#else
344-
345312
/* Since splitting on whitespace is an important use case, and
346313
whitespace in most situations is solely ASCII whitespace, we
347314
optimize for the common case by using a quick look-up table
@@ -371,8 +338,6 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
371338

372339
#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch)
373340

374-
#endif
375-
376341
#define Py_UNICODE_ISALNUM(ch) \
377342
(Py_UNICODE_ISALPHA(ch) || \
378343
Py_UNICODE_ISDECIMAL(ch) || \

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ What's New in Python 3.2 Alpha 3?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #9210: Configure option --with-wctype-functions was removed. Using the
14+
functions from the libc caused the methods .upper() and lower() to become
15+
locale aware and created subtly wrong results.
16+
1317
- Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on
1418
a non-ASCII byte in the format string.
1519

Objects/unicodectype.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ int _PyUnicode_IsPrintable(Py_UCS4 ch)
163163
return (ctype->flags & PRINTABLE_MASK) != 0;
164164
}
165165

166-
#ifndef WANT_WCTYPE_FUNCTIONS
167-
168166
/* Returns 1 for Unicode characters having the category 'Ll', 0
169167
otherwise. */
170168

@@ -223,34 +221,3 @@ int _PyUnicode_IsAlpha(Py_UCS4 ch)
223221
return (ctype->flags & ALPHA_MASK) != 0;
224222
}
225223

226-
#else
227-
228-
/* Export the interfaces using the wchar_t type for portability
229-
reasons: */
230-
231-
int _PyUnicode_IsLowercase(Py_UCS4 ch)
232-
{
233-
return iswlower(ch);
234-
}
235-
236-
int _PyUnicode_IsUppercase(Py_UCS4 ch)
237-
{
238-
return iswupper(ch);
239-
}
240-
241-
Py_UCS4 _PyUnicode_ToLowercase(Py_UCS4 ch)
242-
{
243-
return towlower(ch);
244-
}
245-
246-
Py_UCS4 _PyUnicode_ToUppercase(Py_UCS4 ch)
247-
{
248-
return towupper(ch);
249-
}
250-
251-
int _PyUnicode_IsAlpha(Py_UCS4 ch)
252-
{
253-
return iswalpha(ch);
254-
}
255-
256-
#endif

Objects/unicodetype_db.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,9 +3247,6 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch)
32473247
*/
32483248
int _PyUnicode_IsWhitespace(register const Py_UCS4 ch)
32493249
{
3250-
#ifdef WANT_WCTYPE_FUNCTIONS
3251-
return iswspace(ch);
3252-
#else
32533250
switch (ch) {
32543251
case 0x0009:
32553252
case 0x000A:
@@ -3284,7 +3281,6 @@ int _PyUnicode_IsWhitespace(register const Py_UCS4 ch)
32843281
return 1;
32853282
}
32863283
return 0;
3287-
#endif
32883284
}
32893285

32903286
/* Returns 1 for Unicode characters having the line break

Tools/unicode/makeunicodedata.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,6 @@ def makeunicodetype(unicode, trace):
503503
print(" */", file=fp)
504504
print('int _PyUnicode_IsWhitespace(register const Py_UCS4 ch)', file=fp)
505505
print('{', file=fp)
506-
print('#ifdef WANT_WCTYPE_FUNCTIONS', file=fp)
507-
print(' return iswspace(ch);', file=fp)
508-
print('#else', file=fp)
509506
print(' switch (ch) {', file=fp)
510507

511508
for codepoint in sorted(spaces):
@@ -514,7 +511,6 @@ def makeunicodetype(unicode, trace):
514511

515512
print(' }', file=fp)
516513
print(' return 0;', file=fp)
517-
print('#endif', file=fp)
518514
print('}', file=fp)
519515
print(file=fp)
520516

configure

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,6 @@ with_doc_strings
747747
with_tsc
748748
with_pymalloc
749749
with_valgrind
750-
with_wctype_functions
751750
with_fpectl
752751
with_libm
753752
with_libc
@@ -1418,7 +1417,6 @@ Optional Packages:
14181417
--with(out)-tsc enable/disable timestamp counter profile
14191418
--with(out)-pymalloc disable/enable specialized mallocs
14201419
--with-valgrind Enable Valgrind support
1421-
--with-wctype-functions use wctype.h functions
14221420
--with-fpectl enable SIGFPE catching
14231421
--with-libm=STRING math library
14241422
--with-libc=STRING C library
@@ -9232,28 +9230,6 @@ fi
92329230
OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
92339231
fi
92349232
9235-
# Check for --with-wctype-functions
9236-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-wctype-functions" >&5
9237-
$as_echo_n "checking for --with-wctype-functions... " >&6; }
9238-
9239-
# Check whether --with-wctype-functions was given.
9240-
if test "${with_wctype_functions+set}" = set; then :
9241-
withval=$with_wctype_functions;
9242-
if test "$withval" != no
9243-
then
9244-
9245-
$as_echo "#define WANT_WCTYPE_FUNCTIONS 1" >>confdefs.h
9246-
9247-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
9248-
$as_echo "yes" >&6; }
9249-
else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9250-
$as_echo "no" >&6; }
9251-
fi
9252-
else
9253-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9254-
$as_echo "no" >&6; }
9255-
fi
9256-
92579233
92589234
# -I${DLINCLDIR} is added to the compile rule for importdl.o
92599235

configure.in

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,21 +2493,6 @@ if test "$with_valgrind" != no; then
24932493
OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
24942494
fi
24952495

2496-
# Check for --with-wctype-functions
2497-
AC_MSG_CHECKING(for --with-wctype-functions)
2498-
AC_ARG_WITH(wctype-functions,
2499-
AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
2500-
[
2501-
if test "$withval" != no
2502-
then
2503-
AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2504-
[Define if you want wctype.h functions to be used instead of the
2505-
one supplied by Python itself. (see Include/unicodectype.h).])
2506-
AC_MSG_RESULT(yes)
2507-
else AC_MSG_RESULT(no)
2508-
fi],
2509-
[AC_MSG_RESULT(no)])
2510-
25112496
# -I${DLINCLDIR} is added to the compile rule for importdl.o
25122497
AC_SUBST(DLINCLDIR)
25132498
DLINCLDIR=.

pyconfig.h.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,10 +1077,6 @@
10771077
/* Define if you want SIGFPE handled (see Include/pyfpe.h). */
10781078
#undef WANT_SIGFPE_HANDLER
10791079

1080-
/* Define if you want wctype.h functions to be used instead of the one
1081-
supplied by Python itself. (see Include/unicodectype.h). */
1082-
#undef WANT_WCTYPE_FUNCTIONS
1083-
10841080
/* Define if WINDOW in curses.h offers a field _flags. */
10851081
#undef WINDOW_HAS_FLAGS
10861082

0 commit comments

Comments
 (0)