From feb7307db4b4582af9ac01719f7df651c2eed077 Mon Sep 17 00:00:00 2001 From: Amaury Forgeot d'Arc Date: Sun, 12 Sep 2010 22:42:57 +0000 Subject: [PATCH] #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 ) --- Doc/whatsnew/3.2.rst | 5 +++++ Include/unicodeobject.h | 37 +------------------------------- Misc/NEWS | 4 ++++ Objects/unicodectype.c | 33 ---------------------------- Objects/unicodetype_db.h | 4 ---- Tools/unicode/makeunicodedata.py | 4 ---- configure | 24 --------------------- configure.in | 15 ------------- pyconfig.h.in | 4 ---- 9 files changed, 10 insertions(+), 120 deletions(-) diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst index 7d8b2e61f2d..0f9366da43c 100644 --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -525,6 +525,11 @@ Changes to Python's build process and to the C API include: (Contributed by Antoine Pitrou; :issue:`9203`.) +* The option ``--with-wctype-functions`` was removed. The built-in unicode + database is now used for all functions. + + (Contributed by Amaury Forgeot D'Arc; :issue:`9210`.) + Porting to Python 3.2 ===================== diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 820850ae01a..111d7e230e9 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -78,7 +78,7 @@ Copyright (c) Corporation for National Research Initiatives. #define Py_UNICODE_WIDE #endif -/* Set these flags if the platform has "wchar.h", "wctype.h" and the +/* Set these flags if the platform has "wchar.h" and the wchar_t type is a 16-bit unsigned type */ /* #define HAVE_WCHAR_H */ /* #define HAVE_USABLE_WCHAR_T */ @@ -309,39 +309,6 @@ typedef PY_UNICODE_TYPE Py_UNICODE; /* --- Internal Unicode Operations ---------------------------------------- */ -/* If you want Python to use the compiler's wctype.h functions instead - of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or - configure Python using --with-wctype-functions. This reduces the - interpreter's code size. */ - -#if defined(Py_UNICODE_WIDE) && defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS) - -#include - -#define Py_UNICODE_ISSPACE(ch) iswspace(ch) - -#define Py_UNICODE_ISLOWER(ch) iswlower(ch) -#define Py_UNICODE_ISUPPER(ch) iswupper(ch) -#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) -#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) - -#define Py_UNICODE_TOLOWER(ch) towlower(ch) -#define Py_UNICODE_TOUPPER(ch) towupper(ch) -#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) - -#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) -#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) -#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) -#define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch) - -#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) -#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) -#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) - -#define Py_UNICODE_ISALPHA(ch) iswalpha(ch) - -#else - /* Since splitting on whitespace is an important use case, and whitespace in most situations is solely ASCII whitespace, we optimize for the common case by using a quick look-up table @@ -371,8 +338,6 @@ typedef PY_UNICODE_TYPE Py_UNICODE; #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) -#endif - #define Py_UNICODE_ISALNUM(ch) \ (Py_UNICODE_ISALPHA(ch) || \ Py_UNICODE_ISDECIMAL(ch) || \ diff --git a/Misc/NEWS b/Misc/NEWS index 7b06c69808c..caec74953b6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ What's New in Python 3.2 Alpha 3? Core and Builtins ----------------- +- Issue #9210: Configure option --with-wctype-functions was removed. Using the + functions from the libc caused the methods .upper() and lower() to become + locale aware and created subtly wrong results. + - Issue #9738: PyUnicode_FromFormat() and PyErr_Format() raise an error on a non-ASCII byte in the format string. diff --git a/Objects/unicodectype.c b/Objects/unicodectype.c index f6e32508245..a41ceb82402 100644 --- a/Objects/unicodectype.c +++ b/Objects/unicodectype.c @@ -163,8 +163,6 @@ int _PyUnicode_IsPrintable(Py_UCS4 ch) return (ctype->flags & PRINTABLE_MASK) != 0; } -#ifndef WANT_WCTYPE_FUNCTIONS - /* Returns 1 for Unicode characters having the category 'Ll', 0 otherwise. */ @@ -223,34 +221,3 @@ int _PyUnicode_IsAlpha(Py_UCS4 ch) return (ctype->flags & ALPHA_MASK) != 0; } -#else - -/* Export the interfaces using the wchar_t type for portability - reasons: */ - -int _PyUnicode_IsLowercase(Py_UCS4 ch) -{ - return iswlower(ch); -} - -int _PyUnicode_IsUppercase(Py_UCS4 ch) -{ - return iswupper(ch); -} - -Py_UCS4 _PyUnicode_ToLowercase(Py_UCS4 ch) -{ - return towlower(ch); -} - -Py_UCS4 _PyUnicode_ToUppercase(Py_UCS4 ch) -{ - return towupper(ch); -} - -int _PyUnicode_IsAlpha(Py_UCS4 ch) -{ - return iswalpha(ch); -} - -#endif diff --git a/Objects/unicodetype_db.h b/Objects/unicodetype_db.h index 637f6298cd5..ef18b95cf3f 100644 --- a/Objects/unicodetype_db.h +++ b/Objects/unicodetype_db.h @@ -3247,9 +3247,6 @@ double _PyUnicode_ToNumeric(Py_UCS4 ch) */ int _PyUnicode_IsWhitespace(register const Py_UCS4 ch) { -#ifdef WANT_WCTYPE_FUNCTIONS - return iswspace(ch); -#else switch (ch) { case 0x0009: case 0x000A: @@ -3284,7 +3281,6 @@ int _PyUnicode_IsWhitespace(register const Py_UCS4 ch) return 1; } return 0; -#endif } /* Returns 1 for Unicode characters having the line break diff --git a/Tools/unicode/makeunicodedata.py b/Tools/unicode/makeunicodedata.py index 7266a91c4ec..b2615eefcd1 100644 --- a/Tools/unicode/makeunicodedata.py +++ b/Tools/unicode/makeunicodedata.py @@ -503,9 +503,6 @@ def makeunicodetype(unicode, trace): print(" */", file=fp) print('int _PyUnicode_IsWhitespace(register const Py_UCS4 ch)', file=fp) print('{', file=fp) - print('#ifdef WANT_WCTYPE_FUNCTIONS', file=fp) - print(' return iswspace(ch);', file=fp) - print('#else', file=fp) print(' switch (ch) {', file=fp) for codepoint in sorted(spaces): @@ -514,7 +511,6 @@ def makeunicodetype(unicode, trace): print(' }', file=fp) print(' return 0;', file=fp) - print('#endif', file=fp) print('}', file=fp) print(file=fp) diff --git a/configure b/configure index 8bd1ea5127e..a3826ef169b 100755 --- a/configure +++ b/configure @@ -747,7 +747,6 @@ with_doc_strings with_tsc with_pymalloc with_valgrind -with_wctype_functions with_fpectl with_libm with_libc @@ -1418,7 +1417,6 @@ Optional Packages: --with(out)-tsc enable/disable timestamp counter profile --with(out)-pymalloc disable/enable specialized mallocs --with-valgrind Enable Valgrind support - --with-wctype-functions use wctype.h functions --with-fpectl enable SIGFPE catching --with-libm=STRING math library --with-libc=STRING C library @@ -9232,28 +9230,6 @@ fi OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT" fi -# Check for --with-wctype-functions -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-wctype-functions" >&5 -$as_echo_n "checking for --with-wctype-functions... " >&6; } - -# Check whether --with-wctype-functions was given. -if test "${with_wctype_functions+set}" = set; then : - withval=$with_wctype_functions; -if test "$withval" != no -then - -$as_echo "#define WANT_WCTYPE_FUNCTIONS 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - # -I${DLINCLDIR} is added to the compile rule for importdl.o diff --git a/configure.in b/configure.in index b4672848aeb..c6a51a324a9 100644 --- a/configure.in +++ b/configure.in @@ -2493,21 +2493,6 @@ if test "$with_valgrind" != no; then OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT" fi -# Check for --with-wctype-functions -AC_MSG_CHECKING(for --with-wctype-functions) -AC_ARG_WITH(wctype-functions, - AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]), -[ -if test "$withval" != no -then - AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1, - [Define if you want wctype.h functions to be used instead of the - one supplied by Python itself. (see Include/unicodectype.h).]) - AC_MSG_RESULT(yes) -else AC_MSG_RESULT(no) -fi], -[AC_MSG_RESULT(no)]) - # -I${DLINCLDIR} is added to the compile rule for importdl.o AC_SUBST(DLINCLDIR) DLINCLDIR=. diff --git a/pyconfig.h.in b/pyconfig.h.in index b26b44163ad..545dbe38115 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1077,10 +1077,6 @@ /* Define if you want SIGFPE handled (see Include/pyfpe.h). */ #undef WANT_SIGFPE_HANDLER -/* Define if you want wctype.h functions to be used instead of the one - supplied by Python itself. (see Include/unicodectype.h). */ -#undef WANT_WCTYPE_FUNCTIONS - /* Define if WINDOW in curses.h offers a field _flags. */ #undef WINDOW_HAS_FLAGS