Re: [Pyobjc-dev] import QTKit -> NSRecursiveLock errors
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2009-06-25 15:01:48
|
On 25 Jun, 2009, at 16:38, Dirk Stoop wrote:
> On Jun 25, 2009, at 8:02 AM, Ronald Oussoren wrote:
>
>> However, if you use py2app it should detect 'import' statements in
>> function bodies as well as at the global level. I'd consider it a bug
>> when it doesn't detect import statements in a function/method body.
>
> Ahh. Thanks for the clarification. I use code like the example
> below in some places in Checkout, so those must be the only places
> where py2app – understandibly – misses stuff:
>
> exec("import %s" % someClassName)
> exec("instance = %s.alloc().init()" % someClassName)
That's right. Py2app can only detect imports using the import
statement, those are easily detectable by scanning the bytecode of a
module. Another relativly common way to import code in very dynamic
modules is:
mod = __import__(someClassName)
This emits a regular function call in the bytecode and cannot be
detected by py2app.
BTW. I would use that mechansm rather than your exec statements to
dynamicly import code:
m = __import__(someClassName)
instance = getattr(m, someClassName).alloc().init()
Ronald
>
> - Dirk
|