2.3a2 problem: iconv module raising RuntimeError

There are already 2 bug reports with the build failing because the iconv module raises a RuntimeError. A patch to setup.py is below. The patch corrects the problem, but should anything else be done? The problem is that iconv builds ok, but the iconv_open fails so the module initialization failed, IIRC. Neal -- Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.146 diff -w -u -r1.146 setup.py --- setup.py 18 Feb 2003 10:24:34 -0000 1.146 +++ setup.py 20 Feb 2003 23:09:35 -0000 @@ -207,7 +207,7 @@ self.get_ext_filename(self.get_ext_fullname(ext.name))) try: imp.load_dynamic(ext.name, ext_filename) - except ImportError, why: + except (ImportError, RuntimeError), why: if 1: self.announce('*** WARNING: renaming "%s" since importing it'

There are already 2 bug reports with the build failing because the iconv module raises a RuntimeError. A patch to setup.py is below. The patch corrects the problem, but should anything else be done?
The problem is that iconv builds ok, but the iconv_open fails so the module initialization failed, IIRC.
I don't think this is quite the right fix. Either it should catch all exceptions, not just RuntimeError; after all an extension that fails in init<module> could raise any exception at all; or it should do this business of declaring the module invalid only when ImportError is raised, and ignore other errors (with a less severe warning). I think the second options is better -- after all the shared library built and loaded correctly. The failure may be fixed by other means. --Guido van Rossum (home page: http://www.python.org/~guido/)
Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.146 diff -w -u -r1.146 setup.py --- setup.py 18 Feb 2003 10:24:34 -0000 1.146 +++ setup.py 20 Feb 2003 23:09:35 -0000 @@ -207,7 +207,7 @@ self.get_ext_filename(self.get_ext_fullname(ext.name))) try: imp.load_dynamic(ext.name, ext_filename) - except ImportError, why: + except (ImportError, RuntimeError), why:
if 1: self.announce('*** WARNING: renaming "%s" since importing it'

Neal Norwitz wrote:
There are already 2 bug reports with the build failing because the iconv module raises a RuntimeError. A patch to setup.py is below. The patch corrects the problem, but should anything else be done?
The problem is that iconv builds ok, but the iconv_open fails so the module initialization failed, IIRC.
The init function tries to find out whether the choosen internal encoding (which should be as close as possible to Pythons internal Unicode representation, i.e. Py_UNICODE) requires byte swapping or not. For this it encodes the character '\x01' from 'ASCII' to the chosen encoding. Unfortunately 'ASCII' doesn't seem to be available on Solaris. One solution would be to try 'ISO8859-1' instead of 'ASCII'. (According to SF patch #670715 this works on Irix, while 'ASCII' doesn't). Another solution would be to test various encodings until one is found that works. I'll change the test encoding to 'ISO8859-1' and we'll see what happens. To get a working build even if importing iconv_codec fails, should the import function raise an ImportError instead of a RunTimeError? Bye, Walter Dörwald

On Fri, Feb 21, 2003 at 07:15:51PM +0100, Walter D?rwald wrote:
Neal Norwitz wrote:
There are already 2 bug reports with the build failing because the iconv module raises a RuntimeError. A patch to setup.py is below. The patch corrects the problem, but should anything else be done?
The problem is that iconv builds ok, but the iconv_open fails so the module initialization failed, IIRC.
The init function tries to find out whether the choosen internal encoding (which should be as close as possible to Pythons internal Unicode representation, i.e. Py_UNICODE) requires byte swapping or not. For this it encodes the character '\x01' from 'ASCII' to the chosen encoding.
Unfortunately 'ASCII' doesn't seem to be available on Solaris. One solution would be to try 'ISO8859-1' instead of 'ASCII'. (According to SF patch #670715 this works on Irix, while 'ASCII' doesn't). Another solution would be to test various encodings until one is found that works.
I'll change the test encoding to 'ISO8859-1' and we'll see what happens.
Sounds good. ISO8859-1 is available on every machines that I have.
To get a working build even if importing iconv_codec fails, should the import function raise an ImportError instead of a RunTimeError?
I prefer ImportError than RuntimeError. Even users who have broken iconv library, should be able to run python.(without iconvcodec)
Bye, Walter D?rwald
Regards, Hye-Shik =)
participants (4)
-
Guido van Rossum
-
Hye-Shik Chang
-
Neal Norwitz
-
Walter Dörwald