Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59403

Re: How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'subject:Python': 0.06; 'assuming': 0.09; 'deprecated': 0.09; 'framework.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'runs': 0.10; 'subject:How': 0.10; 'python': 0.11; 'c/c++': 0.16; 'ctypes.': 0.16; 'itself,': 0.16; 'modules.': 0.16; 'presume': 0.16; 'rather,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'set,': 0.16; 'supplied': 0.16; 'traceback.': 0.16; 'url:file': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'addition,': 0.20; '(the': 0.22; 'import': 0.22; 'load': 0.23; 'header:User-Agent:1': 0.23; 'error': 0.23; 'instead.': 0.24; 'sorry,': 0.24; 'specify': 0.24; 'looks': 0.24; 'question': 0.24; "i've": 0.25; 'header:X-Complaints-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'appear': 0.29; 'sets': 0.30; "i'm": 0.30; 'code': 0.31; 'ctypes': 0.31; 'flags': 0.31; 'probably': 0.32; 'url:python': 0.33; 'running': 0.33; 'actively': 0.33; 'framework': 0.33; 'mac': 0.33; 'older': 0.33; 'updated': 0.34; "i'd": 0.34; 'problem': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'library.': 0.36; 'set.': 0.36; 'charset:us- ascii': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'apple': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'skip:u 10': 0.60; 'enclosed': 0.60; 'email addr:gmail.com': 0.63; 'due': 0.66; 'anything.': 0.68; 'influence': 0.74; 'received:204': 0.75; 'article': 0.77; 'received:204.14': 0.84; 'url:cpython': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Deily <nad@acm.org>
Subject Re: How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks?
Date Wed, 13 Nov 2013 19:44:44 -0800
References <c9bc3283-e895-4d9f-a749-fc35497a875e@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 204.14.154.233
User-Agent MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2581.1384400696.18130.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384400696 news.xs4all.nl 15916 [2001:888:2000:d::a6]:54703
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:59403

Show key headers only | View raw


In article <c9bc3283-e895-4d9f-a749-fc35497a875e@googlegroups.com>,
 tcwan99@gmail.com wrote:
> I'm facing a problem with a 3rd party C/C++ Framework (dynamic library) on 
> Mac OS X which I'm trying to import into Python using ctypes. Unfortunately 
> OS X has deprecated a function which is called from the Framework and is no 
> longer available as of 10.8+ (Mtn. Lion, now updated to Mavericks). In 
> addition, there is no recent version of the 3rd party framework available and 
> it does not look like it's actively updated. (The 3rd party framework in 
> question is the Fantom framework/driver for the LEGO Mindstorms NXT/EV3).
> 
> Existing tools using the 3rd party framework runs ok, but attempting to 
> access it using ctypes fails with a Symbol not Found error when Python 2.7.x 
> attempts to dlopen() the library. I suspect it is due to the setting of 
> RTLD_NOW when opening the framework. I'd like to try to specify RTLD_LAZY 
> instead.
> 
> Unfortunately sys.setdlopenflags(0) does not appear to do anything. RTLD_NOW 
> is still set, which I presume overrides RTLD_LAZY if both flags were set. 
> I've tried this with both the Apple supplied python and the version from 
> MacPorts.
> 
> Enclosed is a snippet of the code and the Traceback. Is there a way to force 
> RTLD_NOW off?

I'm not very familiar with ctypes internals but it looks like 
sys.setdlopenflags is not intended to have an influence on ctypes; rather, it 
conditions the Python interpreter's use of dlopen to load shared Python 
modules.  For ctypes itself, it looks like it unconditionally sets RTLD_NOW 
when calling dlopen and probably with good reason:

http://hg.python.org/cpython/file/2.7/Modules/_ctypes/callproc.c#l1432

Sorry, I don't have a suggestion for you, assuming you want to just try to 
ignore the error, other than perhaps running an older version of OS X in a VM 
on 10.8.

-- 
 Ned Deily,
 nad@acm.org

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks? tcwan99@gmail.com - 2013-11-13 17:08 -0800
  Re: How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks? Ned Deily <nad@acm.org> - 2013-11-13 19:44 -0800
    Re: How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks? Tat-Chee Wan <tcwan99@gmail.com> - 2013-11-14 18:30 -0800

csiph-web