[Pythonmac-SIG] Weird Carbon: gestalt: wxPython issue/bug

Ronald Oussoren ronaldoussoren at mac.com
Tue Feb 9 09:14:19 CET 2010

On 7 Feb, 2010, at 15:30, Aahz wrote:

> On Sun, Feb 07, 2010, Ronald Oussoren wrote:
>> On 4 Feb, 2010, at 18:59, Aahz wrote:
>>> On Thu, Feb 04, 2010, Christopher Barker wrote:
>>>> Peter Hanson, on the wxPython list, seems to have identified a bug in  
>>>> the gestalt module, that may be a Carbon issue. It's a bit of an unusual  
>>>> case: it freezes up wxPython, when wx is called from other than the main  
>>>> thread. Robin Dunn suspects that it's a Carbon issue -- gestalt is  
>>>> calling Carbon, and doing so in the main thread, so you are then trying  
>>>> to call Carbon from more than one thread, which may be the cause of the  
>>>> problem. I've confirmed that if you call gestalt from the same thread as  
>>>> wxPython, there is no failure.
>>> I've already complained that mac_ver() causes a crash with
>>> but I'm pretty sure we're not using wx on Mac, just Windows (we're using
>>> AppHelper).
>> Have you filed a bug about that?  Not that doing that in the
>> python.org tracker would result result in a satisfying resolution:
>> mac_ver calls OSX APIs that don't work in child processes created with
>> fork (but without exec) and that cannot be changed. This was safe
>> in 10.5 and earlier as well, 10.6 is the first version that loudly
>> complains that you do something unsafe.
> Not yet, I was hoping someone else could confirm the bug before filing.
> If you think I should go ahead and file it, I will.  

Filing a bug would help remind me that someone ran into an issue. I won't be able to fix the gestalt issue itself, but it is possible to work around it by calling different APIs to fetch the required information.

> Do you know of any
> other way to get the info that gestalt provides?  

That depends on what you want to know. Platform.mac_ver returns three values: system version, release info and CPU architecture. The second one is always ('', '', '') on OSX and can be ignored.

The system version can also be read from /System/Library/CoreServices/SystemVersion.plist

The CPU architecture can also be deduced from sys.byteorder (if that's "little" your on i386, otherwise you're on ppc). 

> Are you saying that if
> I called mac_ver() in the startup process it should work?

Calling mac_ver() in the startup process is safe.  The problem only affects child processes started using fork without exec.

> -- 
> Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/
> import antigravity
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3567 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20100209/57eb4e57/attachment.bin>

More information about the Pythonmac-SIG mailing list