Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'importing': 0.04; 'messages.': 0.04; 'seemed': 0.07; 'works.': 0.07; 'wrapped': 0.07; 'python': 0.09; 'hashlib': 0.09; 'imports': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'wraps': 0.09; 'subject:error': 0.11; 'up-to-date': 0.13; 'conflicting': 0.16; 'guessing': 0.16; 'loaded.': 0.16; 'modules,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'skip:/ 50': 0.16; 'smtplib': 0.16; 'this).': 0.16; 'version).': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'duplicate': 0.17; 'tries': 0.17; 'jan': 0.18; 'appears': 0.18; 'windows': 0.19; 'load': 0.19; 'import': 0.21; 'latter': 0.22; 'libraries': 0.22; 'modifying': 0.22; 'errors': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'logging': 0.27; 'question': 0.27; 'functions.': 0.27; 'replace': 0.27; 'header:X-Complaints-To:1': 0.28; 'this?': 0.28; 'hash': 0.29; 'case,': 0.29; 'probably': 0.29; "i'm": 0.29; 'version,': 0.30; 'function': 0.30; 'error': 0.30; 'up.': 0.31; 'code': 0.31; '(and': 0.32; 'gets': 0.32; 'system,': 0.32; 'file': 0.32; 'more,': 0.32; 'could': 0.32; 'info': 0.32; 'getting': 0.33; 'loading': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'version': 0.34; 'eric': 0.35; 'expected': 0.35; 'pm,': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'loaded': 0.36; 'should': 0.36; 'enough': 0.36; 'does': 0.37; 'two': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'remove': 0.61; 'first': 0.61; 'latest': 0.61; 'show': 0.63; 'messed': 0.84; 'received:fios.verizon.net': 0.84; 'reminds': 0.84; 'skip:/ 30': 0.91; 'from.': 0.93; 'old.': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: error importing smtplib Date: Fri, 16 Nov 2012 17:00:22 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353103238 news.xs4all.nl 6972 [2001:888:2000:d::a6]:44128 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33453 On 11/16/2012 2:37 PM, Eric Frederich wrote: > So I inspected the process through /proc//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