[Python-bugs-list] [ python-Bugs-508779 ] Disable flat namespace on MacOS X
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 25 Jan 2002 20:25:14 -0800
Bugs item #508779, was opened at 2002-01-25 19:44
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=508779&group_id=5470
Category: Extension Modules
Group: Python 2.2.1 candidate
Status: Open
Resolution: None
Priority: 5
Submitted By: Manoj Plakal (terabaap)
Assigned to: Nobody/Anonymous (nobody)
Summary: Disable flat namespace on MacOS X
Initial Comment:
Python: v2.2
OS: MacOS X 10.1
MacOS X 10.1 introduced two forms of linking
for loadable modules: flat namespace and
two-level namespace.
Python 2.2 is set up to use flat namespace
by default on OS X for building extension modules.
I believe that this is a problem since
it introduces spurious run-time linking
errors when loading 2 or more modules that
happen to have common symbols. The Linux
and Windows implementations do not allow
symbols within modules to clash with
each other. This behavior also goes against
expectations of C extension module writers.
As a reproducible example, consider
two dummy modules foo (foomodule.c)
and bar (barmodule.c) both of which
are built with a common file baz.c
that contains some data variables.
With the current Python 2.2 on OS X 10.1,
only one of foo or bar can be imported,
but NOT BOTH, into the same interpreter
session.
The files can be picked up from
these URLs:
http://yumpee.org/python/foomodule.c
http://yumpee.org/python/barmodule.c
http://yumpee.org/python/baz.c
http://yumpee.org/python/setup.py
If I run "python setup.py build" with
Python 2.2 (built from the 2.2
source tarball) and then import
foo followed by bar, I get an
ImportError: "Failure linking new
module" (from Python/dynload_next.c).
If I add a call to NSLinkEditError()
to print a more detailed error message,
I see that the problem is multiple definitions
of the data variables in baz.c.
The above example works fine with Python 2.1
on Red Hat Linux 7.2 and Python 2.2a4 on Win98.
If I then edit /usr/local/lib/python2.2/Makefile
and change LDSHARED and BLDSHARED to
not use flat_namespace:
$(CC) $(LDFLAGS) -bundle -bundle_loader
/usr/local/bin/python2.2 -undefined error
then the problem is solved and I can load
both foo and bar without problems.
More info and discussion is available at
these URLs (also search groups.google.com
for "comp.lang.python OS X import bug"):
http://groups.google.com/groups?hl=en&threadm=j4sn8uu517.fsf%40informatik.hu-berlin.de&prev=/groups%3Fnum%3D25%26hl%3Den%26group%3Dcomp.lang.python%26start%3D75%26group%3Dcomp.lang.python
http://mail.python.org/pipermail/pythonmac-sig/2002-January/004977.html
It would be great to have this simple
change be applied to Python 2.2.1.
Manoj
terabaap@yumpee.org
----------------------------------------------------------------------
>Comment By: Manoj Plakal (terabaap)
Date: 2002-01-25 20:25
Message:
Logged In: YES
user_id=150105
Another idea is to provide the option for
flat or 2-level namespace when building
extension modules on OS X, maybe as
an extra flag passed to distutils.core.Extension
or somewhere else ...
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=508779&group_id=5470