[Python-checkins] python/dist/src/Lib/test test___all__.py,1.27,1.28

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Wed, 09 Oct 2002 11:17:08 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv17662

Modified Files:
	test___all__.py 
Log Message:
Add special consideration for rlcompleter.  As a side effect of
initializing GNU readline, setlocale(LC_CTYPE, "") is called, which
changes the <ctype.h> macros to use the "default" locale (which isn't
the *initial* locale -- the initial locale is the "C" locale in which
only ASCII characters are printable).  When the default locale is e.g.
Latin-1, the repr() of string objects can include 8-bit characters
with the high bit set; I believe this is due to the recent
PRINT_MULTIBYTE_STRING changes to stringobject.c.  This in turn screws
up test_pyexpat and test_rotor, which depend on the repr() of 8-bit
strings with high bit characters.

The solution (for now) is to force the LC_CTYPE locale to "C" after
importing rlcompleter.  This is the locale required by the test suite
anyway.


Index: test___all__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test___all__.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** test___all__.py	30 Jul 2002 23:26:00 -0000	1.27
--- test___all__.py	9 Oct 2002 18:17:06 -0000	1.28
***************
*** 133,137 ****
  check_all("rexec")
  check_all("rfc822")
- check_all("rlcompleter")
  check_all("robotparser")
  check_all("sched")
--- 133,136 ----
***************
*** 162,163 ****
--- 161,174 ----
  check_all("xdrlib")
  check_all("zipfile")
+ 
+ # rlcompleter needs special consideration; it import readline which
+ # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-(
+ try:
+     check_all("rlcompleter")
+ finally:
+     try:
+         import locale
+     except ImportError:
+         pass
+     else:
+         locale.setlocale(locale.LC_CTYPE, 'C')