Fix SF bug #690012 (among others), iconv_codec stops build

Change setup.py to catch all exceptions.
  - Rename module if the exception was an ImportError
  - Only warn if the exception was any other error

Revert _iconv_codec to raising a RuntimeError.
This commit is contained in:
Neal Norwitz 2003-02-28 17:21:39 +00:00
parent edaa071eb4
commit 3f5fcc8acc
2 changed files with 8 additions and 6 deletions

View File

@ -674,14 +674,14 @@ init_iconv_codec(void)
iconv_t hdl = iconv_open(UNICODE_ENCODING, "ISO-8859-1"); iconv_t hdl = iconv_open(UNICODE_ENCODING, "ISO-8859-1");
if (hdl == (iconv_t)-1) { if (hdl == (iconv_t)-1) {
PyErr_SetString(PyExc_ImportError, PyErr_SetString(PyExc_RuntimeError,
"can't initialize the _iconv_codec module: iconv_open() failed"); "can't initialize the _iconv_codec module: iconv_open() failed");
return; return;
} }
res = iconv(hdl, &inptr, &insize, &outptr, &outsize); res = iconv(hdl, &inptr, &insize, &outptr, &outsize);
if (res == (size_t)-1) { if (res == (size_t)-1) {
PyErr_SetString(PyExc_ImportError, PyErr_SetString(PyExc_RuntimeError,
"can't initialize the _iconv_codec module: iconv() failed"); "can't initialize the _iconv_codec module: iconv() failed");
return; return;
} }
@ -698,7 +698,7 @@ init_iconv_codec(void)
byteswap = 1; byteswap = 1;
else { else {
iconv_close(hdl); iconv_close(hdl);
PyErr_SetString(PyExc_ImportError, PyErr_SetString(PyExc_RuntimeError,
"can't initialize the _iconv_codec module: mixed endianess"); "can't initialize the _iconv_codec module: mixed endianess");
return; return;
} }

View File

@ -207,9 +207,10 @@ class PyBuildExt(build_ext):
self.get_ext_filename(self.get_ext_fullname(ext.name))) self.get_ext_filename(self.get_ext_fullname(ext.name)))
try: try:
imp.load_dynamic(ext.name, ext_filename) imp.load_dynamic(ext.name, ext_filename)
except ImportError, why: except:
if 1: exc_type, why, tb = sys.exc_info()
if issubclass(exc_type, ImportError):
self.announce('*** WARNING: renaming "%s" since importing it' self.announce('*** WARNING: renaming "%s" since importing it'
' failed: %s' % (ext.name, why), level=3) ' failed: %s' % (ext.name, why), level=3)
assert not self.inplace assert not self.inplace
@ -231,7 +232,8 @@ class PyBuildExt(build_ext):
self.announce('unable to remove files (ignored)') self.announce('unable to remove files (ignored)')
else: else:
self.announce('*** WARNING: importing extension "%s" ' self.announce('*** WARNING: importing extension "%s" '
'failed: %s' % (ext.name, why), level=3) 'failed with %s: %s' % (ext.name, exc_type, why),
level=3)
def get_platform (self): def get_platform (self):
# Get value of sys.platform # Get value of sys.platform