Re: error importing smtplib

Discussion in 'Python' started by Terry Reedy, Nov 16, 2012.

  1. Terry Reedy

    Terry Reedy Guest

    On 11/16/2012 2:37 PM, Eric Frederich wrote:
    > So I inspected the process through /proc/<pid>/maps
    > That seemed to show what libraries had been loaded (though there is
    > probably an easier way to do this).


    > In any case, I found that if I import smtplib before logging in I see
    > these get loaded...
    >
    > /opt/foo/python27/lib/python2.7/lib-dynload/_ssl.so
    > /lib64/libssl.so.0.9.8e
    >
    > Then after logging in, I see this other .so get loaded...
    >
    > /opt/bar/lib64/libssl.so.0.9.7


    That version appears to be about a decade old. Why is bar using it?

    > So that is what happens when when things are well and I don't get any
    > error messages.
    > However, when I do the log in first I see the /opt/bar .so file loaded first
    >
    > /opt/bar/lib64/libssl.so.0.9.7
    >
    > Then after importing smtplib I see the other two show up...
    >
    > /opt/foo/python27/lib/python2.7/lib-dynload/_ssl.so
    > /lib64/libssl.so.0.9.8e


    What I know is that hashlib.py imports _hashlib (compilied .c) and that
    the latter wraps libssl, or calls _ssl.so which wraps libssl. In *nix
    this is expected to already be on the system, so in not distributed with
    python. Furthermore, hashlib requires a version recent enough to have
    the latest (best) hash functions. I suspect decade-old 9.9.7 does not
    qualify.

    What I don't know is how .so loading and linking works. It seems that
    two version get loaded but linking gets messed up. This reminds me of
    'dll hell' on Windows ;-). I don't know either if modifying the loading
    of ...9.7 in for or bar code could do anything.

    > So.... I'm guessing the problem is that after I log in, the process has
    > a conflicting libssl.so file loaded.
    > Then when I try to import smtplib it tries getting things from there and
    > that is where the errors are coming from.
    >
    > The question now is how do I fix this?


    [easy] Do the import before the function call, which is the proper order
    and the one that works.

    Remove ...9.7 from bar/lib64/ and have bar use the up-to-date system
    version, like python does. An alternative is to replace ...9.7 with a
    duplicate ...9.8e (and probably better, only load it if there is no
    system version).

    > What else should I be checking?


    Thinking more, you can look at sys.modules, but this does not have any
    info about non-module libraries wrapped by modules, even if the latter
    are C-coded.

    --
    Terry Jan Reedy
    Terry Reedy, Nov 16, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Evan
    Replies:
    3
    Views:
    460
  2. Terry Reedy

    Re: error importing smtplib

    Terry Reedy, Nov 15, 2012, in forum: Python
    Replies:
    0
    Views:
    191
    Terry Reedy
    Nov 15, 2012
  3. Terry Reedy

    Re: error importing smtplib

    Terry Reedy, Nov 15, 2012, in forum: Python
    Replies:
    0
    Views:
    178
    Terry Reedy
    Nov 15, 2012
  4. Dieter Maurer

    Re: error importing smtplib

    Dieter Maurer, Nov 16, 2012, in forum: Python
    Replies:
    0
    Views:
    193
    Dieter Maurer
    Nov 16, 2012
  5. Dieter Maurer

    Re: error importing smtplib

    Dieter Maurer, Nov 18, 2012, in forum: Python
    Replies:
    0
    Views:
    178
    Dieter Maurer
    Nov 18, 2012
Loading...

Share This Page