On Mon, Feb 27, 2006 at 10:23:12AM -0600, John Hunter wrote:
> >>>>> "Albert" == Albert Chin <matplotlib-devel@...> writes:
> Albert> The problem is duplicate function names. An error occurs
> Albert> because set_bg() is contained in more than one loadable
> Albert> module, and the wrong one is selected at
> Albert> runtime. examples/image_demo.py won't run because Python
> Albert> gives an AttributeError in lib/matplotlib/image.py, line
> Albert> 141: im.set_bg( *bg)
> I'm confused here. The only extension code that defines set_bg is the
> _image module
But src/_image.cpp is built into _n?_backend_agg.so and _n?_image.so.
We really don't want duplicate symbols in loadable modules if they
will be loaded at once.
> johnh@...> grep set_bg *.h
> _image.h: Py::Object set_bg(const Py::Tuple& args);
> _image.h: static char set_bg__doc__;
> I don't see why you should be having a problem with this. Can you
> submit a complete traceback?
$ python image_demo.py
Traceback (most recent call last):
File "image_demo.py", line 14, in ?
File "/tmp/m/matplotlib/pylab.py", line 839, in savefig
return fig.savefig(*args, **kwargs)
File "/tmp/m/matplotlib/figure.py", line 654, in savefig
File "/tmp/m/matplotlib/backends/backend_gtkagg.py", line 111, in print_figure
agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
File "/tmp/m/matplotlib/backends/backend_agg.py", line 447, in print_figure
File "/tmp/m/matplotlib/backends/backend_agg.py", line 384, in draw
File "/tmp/m/matplotlib/figure.py", line 529, in draw
for a in self.axes: a.draw(renderer)
File "/tmp/m/matplotlib/axes.py", line 1420, in draw
File "/tmp/m/matplotlib/image.py", line 206, in draw
im = self.make_image()
File "/tmp/m/matplotlib/image.py", line 141, in make_image
The AttributeError is kinda odd though. If I print 'im', I get:
<Image object at 0x40cdd374>
Regardless of whether or not Image is picked from _na_backend_agg.so
or _na_image.so, you'd think im.set_bg() would be available. However,
removing the duplicate src/_image.cpp file from being included in
_n?_backend_agg.so solved things.
> Albert> Also, src/mplutils.cpp is included multiple times but I
> Albert> haven't encountered any errors because of this yet.
> This shouldn't pose a problem as long as there isn't a global
> variable, right? My understanding is that the ft2font problem arises
> because of the use of the global FT_Library _ft2Library .
_image.o is linked into _n?_backend_agg.so and _n?_image.so. Both will
be loaded at runtime.
I don't think the problem is limited to global variables. Rather, I'd
say duplicate symbols. According to one of the GCC developers (who
specializes in HP-UX/PA):
When a weak symbol is linked into a shared library, it becomes a
strong global symbol. So, if the symbol appears in more than one
shared object, then you can can get the problem that you found. This
is one area where the HP linker differs from the SYSV ABI. The other
is in the handling of undefined weak symbols.
The default object file format on HP-UX/PA is SOM, not ELF. HP-UX/IA
is ELF and HP-UX/PA 64-bit is ELF.
albert chin (china@...)