OS X import bug?

Steven Majewski sdm7g at Virginia.EDU
Thu Jan 24 15:49:10 EST 2002


On Thu, 24 Jan 2002, Manoj Plakal wrote:

> Python 2.2+ (#1, Jan 17 2002, 10:33:30)
> [GCC 2.95.2 19991024 (release)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import foo
> var_for_foo = 1
>  >>> import bar
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
> ImportError: Failure linking new module
>  >>>

I believe whenever I had a problem with duplicate symbols, the error
message actually said something about duplicate symbols.


The 'Failure linking new module' is the error I got from the
the 'PyObject_DelItemString' problem:
http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=498915

(But the symptom of working for one import but not the other doesn't
 sound right.)
This bug was in 2.2. I don't know if it's fixed in the 2.2+ you seem
to be running, but it's worth checking.


Below is a patch that adds a call to NSLinkEditError, which will
give you a more explicit error message about what's wrong. It's
how I discovered which symbol was the problem with that bug:

>>> import pyobjc
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: dyld: /usr/local/src/Python-2.2/python.exe Undefined symbols:
_PyObject_DelItemString
Failure linking new module
>>>


-- Steve


*** dynload_next.c.0	Fri Jan 18 13:50:06 2002
--- dynload_next.c	Fri Jan 18 14:08:13 2002
***************
*** 150,157 ****
  		if (errString == NULL) {
  			newModule = NSLinkModule(image, pathname,
  				NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR);
! 			if (!newModule)
! 				errString = "Failure linking new module";
  		}
  		if (errString != NULL) {
  			PyErr_SetString(PyExc_ImportError, errString);
--- 150,164 ----
  		if (errString == NULL) {
  			newModule = NSLinkModule(image, pathname,
  				NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR);
! 			if (!newModule) {  // sdm7g
! 			  int errNo;
! 			  char *fileName, *moreErrorStr;
! 			  NSLinkEditErrors c;
! 			  errString = "Failure linking new module";
! 			  NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr );
! 			  errString = strcat( fileName, errString );
! 			  errString = strcat( moreErrorStr, errString );
! 			} // sdm7g
  		}
  		if (errString != NULL) {
  			PyErr_SetString(PyExc_ImportError, errString);







More information about the Python-list mailing list