pyobjc-dev Mailing List for PyObjC (Page 42)
Brought to you by:
ronaldoussoren
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(30) |
May
(18) |
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2002 |
Jan
(7) |
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
(3) |
Jul
(13) |
Aug
|
Sep
(23) |
Oct
(180) |
Nov
(291) |
Dec
(95) |
2003 |
Jan
(338) |
Feb
(352) |
Mar
(97) |
Apr
(46) |
May
(226) |
Jun
(184) |
Jul
(145) |
Aug
(141) |
Sep
(69) |
Oct
(161) |
Nov
(96) |
Dec
(90) |
2004 |
Jan
(66) |
Feb
(87) |
Mar
(98) |
Apr
(132) |
May
(115) |
Jun
(68) |
Jul
(150) |
Aug
(92) |
Sep
(59) |
Oct
(52) |
Nov
(17) |
Dec
(75) |
2005 |
Jan
(84) |
Feb
(191) |
Mar
(133) |
Apr
(114) |
May
(158) |
Jun
(185) |
Jul
(62) |
Aug
(28) |
Sep
(36) |
Oct
(88) |
Nov
(65) |
Dec
(43) |
2006 |
Jan
(85) |
Feb
(62) |
Mar
(92) |
Apr
(75) |
May
(68) |
Jun
(101) |
Jul
(73) |
Aug
(37) |
Sep
(91) |
Oct
(65) |
Nov
(30) |
Dec
(39) |
2007 |
Jan
(24) |
Feb
(28) |
Mar
(10) |
Apr
(2) |
May
(18) |
Jun
(16) |
Jul
(21) |
Aug
(6) |
Sep
(30) |
Oct
(31) |
Nov
(153) |
Dec
(31) |
2008 |
Jan
(63) |
Feb
(70) |
Mar
(47) |
Apr
(24) |
May
(59) |
Jun
(22) |
Jul
(12) |
Aug
(7) |
Sep
(14) |
Oct
(26) |
Nov
(5) |
Dec
(5) |
2009 |
Jan
(10) |
Feb
(41) |
Mar
(70) |
Apr
(88) |
May
(49) |
Jun
(62) |
Jul
(34) |
Aug
(15) |
Sep
(55) |
Oct
(40) |
Nov
(67) |
Dec
(21) |
2010 |
Jan
(60) |
Feb
(17) |
Mar
(26) |
Apr
(26) |
May
(29) |
Jun
(4) |
Jul
(21) |
Aug
(21) |
Sep
(10) |
Oct
(12) |
Nov
(3) |
Dec
(19) |
2011 |
Jan
(3) |
Feb
(13) |
Mar
(8) |
Apr
(8) |
May
(17) |
Jun
(20) |
Jul
(21) |
Aug
(7) |
Sep
|
Oct
|
Nov
(9) |
Dec
(11) |
2012 |
Jan
(3) |
Feb
|
Mar
|
Apr
(5) |
May
(4) |
Jun
(14) |
Jul
(5) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(23) |
Dec
(1) |
2013 |
Jan
(8) |
Feb
(1) |
Mar
|
Apr
|
May
(5) |
Jun
(1) |
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(12) |
Nov
(10) |
Dec
(3) |
2014 |
Jan
(7) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(2) |
Jun
(11) |
Jul
(10) |
Aug
(4) |
Sep
|
Oct
(8) |
Nov
(1) |
Dec
(2) |
2015 |
Jan
(9) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(7) |
Jun
|
Jul
(5) |
Aug
(6) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
2016 |
Jan
(1) |
Feb
(1) |
Mar
(4) |
Apr
(2) |
May
(1) |
Jun
|
Jul
(6) |
Aug
(8) |
Sep
(21) |
Oct
(17) |
Nov
|
Dec
(36) |
2017 |
Jan
(6) |
Feb
(2) |
Mar
(4) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(6) |
2018 |
Jan
(2) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
(2) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(6) |
Oct
(16) |
Nov
(1) |
Dec
(6) |
2019 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(7) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(2) |
Dec
(1) |
2021 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(5) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2025 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Dirk S. <dir...@ma...> - 2009-07-12 14:01:42
|
Hi all, We've been trying to use the objc.synthesize method in our project, but ran into some issues with it. After peeking in pyobjc-core for a bit, I think I might have found a bug. At line 186 and beyond (def synthesize), in: > http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-core/Lib/objc/_descriptors.py , the generated setter strings use name.capitalize() to go from 'ivar' to 'setIvar_'. This works as expected on variable names with only lowercase characters, but has an undesired effect on names with camelCase in them. examples: name = 'string' resulting setter method name = 'setString_' name = 'searchString' resulting setter method name = 'setSearchstring_' expected setter method name = 'setSearchString_' If we replace: > name=name.capitalize() with: > name = '%s%s' % (name[0].upper(), name[1:]) It should be fixed, but using the [1:] indexset means that an IndexError will be thrown for names with zero length. (Though that doesn't sound like a big deal to me, we might want to provide a better description than 'index out of range' when that happens). I can't build from trunk right now, so it's a bit of a hassle for me to actually test this fix, hence this email instead of a patch. @Ronald: Please let me know if you want to hear about specific problems building on 10.5 right now, (or if you'd like me to submit patches with fixes for those problems, let me know how you prefer those patches to be formatted). Thanks :) - Dirk |
From: James R E. <Jam...@lr...> - 2009-07-11 11:16:47
|
Hi Jean-Pierre, The problem you're having is actually at the print statement at the very end. The problem is that your sys.stdout.defaultencoding is usually set to US-ASCII rather than UTF8. Unfortunately, the pythonic way of changing this encoding is via the site-config file, which you can't very well distribute with your python application. You can either restrict yourself to NSLog, which does properly output UTF-8 encoded unicode text, or you can manually encode your output via: print error.localizedDescription().encode('utf8') This approach is better suited if you can bury that deep inside your own logging-like mechanism, since you don't want a single missed ".encode('utf8')" to introduce a unicode bug to your code. If anyone has any alternative suggestions, btw, I'd love to hear them. Unicode in python is often a source of headaches. Cheers! James Le 11 juil. 09 à 11:18, Jean-Pierre a écrit : > Hello, > > I am having problems to get the localized error message from an > NSError object. > > The following code runs fine when launched as a simple script in the > Terminal: > > from Foundation import * > url = NSURL.URLWithString_("http://invalid") > request = NSURLRequest.requestWithURL_(url) > (data, response, error)= > NSURLConnection > .sendSynchronousRequest_returningResponse_error_(request) > NSLog("error:%@", error.localizedDescription()) > print unicode(error.localizedDescription()) > > But fails with an UnicodeError Exception: <type > 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character > u'\u2019' in position 3: ordinal not in range(128) > when ran from a Cocoa-Python Application project from Xcode. > The error string has indeed an non ascii character in its fourth > position ("can’t find host"), but the type of the > error.localizedDescription() object is objc.pyobjc_unicode so it > shouldn't be a problem. > > Am I doing something wrong ? > > Thanks, > > - Jean-Pierre. > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited > time, > vendors submitting new applications to BlackBerry App World(TM) will > have > the opportunity to enter the BlackBerry Developer Challenge. See > full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Jean-Pierre <cho...@fr...> - 2009-07-11 09:31:02
|
Hello, I am having problems to get the localized error message from an NSError object. The following code runs fine when launched as a simple script in the Terminal: from Foundation import * url = NSURL.URLWithString_("http://invalid") request = NSURLRequest.requestWithURL_(url) (data, response, error)= NSURLConnection.sendSynchronousRequest_returningResponse_error_(request) NSLog("error:%@", error.localizedDescription()) print unicode(error.localizedDescription()) But fails with an UnicodeError Exception: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\u2019' in position 3: ordinal not in range(128) when ran from a Cocoa-Python Application project from Xcode. The error string has indeed an non ascii character in its fourth position ("can’t find host"), but the type of the error.localizedDescription() object is objc.pyobjc_unicode so it shouldn't be a problem. Am I doing something wrong ? Thanks, - Jean-Pierre. |
From: Dirk S. <dir...@ma...> - 2009-07-08 12:07:47
|
On Jul 8, 2009, at 1:58 PM, Ronald Oussoren wrote: > > On 8 Jul, 2009, at 13:51, Dirk Stoop wrote: > >> Hi Ronald, >> >> Thanks for this. No worries about taking a while to get to it, I'm >> very grateful. :) >> >> I'll check out r2261 to see if I can start using that revision >> (still on 2.2b2 right now) for Checkout. >> >> Looking at where the problem lies, this probably also fixes the >> problems I encountered with .new() before. Funny how those two >> issues seem to be related again. > > Maybe not, the +new issue is separate from this issue. The two-line > explanation for that issue: > > * The real world: +new { return [[self alloc] init]; } > * PyObjC's world: +new { return [[[self alloc] init] autorelease]; } > > This causes refcount leaks because PyObjC doesn't know that it owns > the reference that new returns, and hence should call > -release sometime later. I have a fix for that in my tree, but > that's to intertwined with SL related code to easily push to the > repository. > > The easiest workaround for now: don't use 'SomeClass.new()' but use > 'SomeClass.alloc().init()'. > > Ronald Ah, that makes sense. I already did a global find and replace on new() — not going back anytime soon. Cheers, - Dirk |
From: Ronald O. <ron...@ma...> - 2009-07-08 11:58:48
|
On 8 Jul, 2009, at 13:51, Dirk Stoop wrote: > Hi Ronald, > > Thanks for this. No worries about taking a while to get to it, I'm > very grateful. :) > > I'll check out r2261 to see if I can start using that revision > (still on 2.2b2 right now) for Checkout. > > Looking at where the problem lies, this probably also fixes the > problems I encountered with .new() before. Funny how those two > issues seem to be related again. Maybe not, the +new issue is separate from this issue. The two-line explanation for that issue: * The real world: +new { return [[self alloc] init]; } * PyObjC's world: +new { return [[[self alloc] init] autorelease]; } This causes refcount leaks because PyObjC doesn't know that it owns the reference that new returns, and hence should call -release sometime later. I have a fix for that in my tree, but that's to intertwined with SL related code to easily push to the repository. The easiest workaround for now: don't use 'SomeClass.new()' but use 'SomeClass.alloc().init()'. Ronald > > Thanks again, > - Dirk > > On Jul 8, 2009, at 1:14 PM, Ronald Oussoren wrote: > >> Refcounts are annoying.... Actually understanding what was going >> wrong was slightly harder than I had expected, but I managed to >> find and fix the bug. >> >> The end of the output of your example when I close the window is now: >> >> 2009-07-08 13:05:24.955 TopLevelLeaker[71318:903] dealloc in >> <TLWindowController: 0x104d46780> >> 2009-07-08 13:05:24.957 TopLevelLeaker[71318:903] dealloc in >> <TLPythonInitView: 0x104d49d50> >> 2009-07-08 13:05:24.958 TopLevelLeaker[71318:903] dealloc in >> <TLVanillaArrayController: 0x104f71b40>[object class: >> NSMutableDictionary, number of selected objects: 0] >> 2009-07-08 13:05:24.959 TopLevelLeaker[71318:903] dealloc in >> <TLVanillaView: 0x104f76140> >> 2009-07-08 13:05:24.961 TopLevelLeaker[71318:903] dealloc called in >> <TLPythonInitArrayController: 0x104f72110>[object class: >> NSMutableDictionary, number of selected objects: 0] >> >> As you can see the program now correctly deallocs both the >> PythonInitView and the VanillaView. >> >> I've committed the fix as r2261. This is however a partial commit >> from my working tree, I'm pretty sure I included just the right >> amount of changes to truly fix the issue. I cannot do a full commit >> at the moment because my working tree contains SnowLeopard-related >> code which cannot be released because SL is under NDA. >> >> Ronald >> >> On 8 Jul, 2009, at 11:35, Ronald Oussoren wrote: >> >>> Dirk, >>> >>> Sorry about the slow response, it's busy at work and haven't been >>> able >>> to find time to dive into this until now. >>> >>> The good news is that this issue is unrelated to NIB files, making >>> it >>> a lot easier to debug than I feared that it would be. The bad news >>> is >>> that there seems to be a serious memory leak in PyObjC when >>> instances >>> are created in ObjC code but have a Python initializer. >>> >>> I currently have a testcase with some ObjC code that calls [[cls >>> alloc] init] on an arbitrary class. When I create an object using >>> this >>> code in class that has a Python init method, the instance is never >>> released. When the (Python) class does not have a Python init method >>> it will be released. >>> >>> Now that I have a pretty simple testcase that reproduces the issue >>> I'm >>> hopeful that I'll be able to fix the issue soon, and keep it fixed. >>> The failure mode also points to a fairly specific path through the >>> code, which should help in pinpointing the issue. >>> >>> BTW. This does not affect creating new instances from Python code, >>> which is probably why this is only really noticable in some specific >>> contexts. >>> >>> Ronald >>> >>> On 23 Jun, 2009, at 14:52, Dirk Stoop wrote: >>> >>>> Hi Ronald, >>>> >>>> A sample app that demonstrates the isolated issue is attached. See >>>> the README.txt in the archive for a quick overview. >>>> >>>> <TopLevelLeaker.zip> >>>> >>>> Cheers, >>>> -Dirk >>>> >>>> On Jun 23, 2009, at 10:55 AM, Ronald Oussoren wrote: >>>> >>>>> Dirk, >>>>> >>>>> On 23 Jun, 2009, at 10:32, Dirk Stoop wrote: >>>>> >>>>>> Hi Ronald, >>>>>> >>>>>> I use objc.IBOutlet() all over the place, so I've tried a >>>>>> couple of >>>>>> things. >>>>> >>>>> I just thought of an easier way to do this: before importing any >>>>> PyObjC classes do: import objc; objc.IBOutlet = objc.ivar. I >>>>> wonder >>>>> why I didn't think of that earlier :-( >>>>> >>>>>> >>>>>> Short summary is: It definitely changes behavior, but it doesn't >>>>>> solve the problem. >>>>>> >>>>>> I've tried the following things: >>>>>> >>>>>> 1. Add an objc.ivar() definition (with the same name) after an >>>>>> outlet definition to a top-level object that has an init method >>>>>> implemented in Python. >>>>>> 2. Add an objc.ivar() definition (with the same name) after an >>>>>> outlet definition to a top-level object that's a vanilla Cocoa >>>>>> class. >>>>>> 3. Add an objc.ivar() definition (again, the same name) after an >>>>>> outlet definition to a non-top-level object that's implemented >>>>>> with >>>>>> Python, but doesn't override the designated initializer. >>>>> >>>>> Could you create a small application that demonstrates the >>>>> problem? >>>>> That would make testing on my side a lot easier. >>>>> >>>>> Ronald >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Are you an open source citizen? Join us for the Open Source Bridge >>>>> conference! >>>>> Portland, OR, June 17-19. Two days of sessions, one day of >>>>> unconference: $250. >>>>> Need another reason to go? 24-hour hacker lounge. Register today! >>>>> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org >>>>> _______________________________________________ >>>>> Pyobjc-dev mailing list >>>>> Pyo...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >>>> >>>> ------------------------------------------------------------------------------ >>>> Are you an open source citizen? Join us for the Open Source Bridge >>>> conference! >>>> Portland, OR, June 17-19. Two days of sessions, one day of >>>> unconference: $250. >>>> Need another reason to go? 24-hour hacker lounge. Register today! >>>> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org_______________________________________________ >>>> Pyobjc-dev mailing list >>>> Pyo...@li... >>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >>> >>> >>> ------------------------------------------------------------------------------ >>> Enter the BlackBerry Developer Challenge >>> This is your chance to win up to $100,000 in prizes! For a limited >>> time, >>> vendors submitting new applications to BlackBerry App World(TM) >>> will have >>> the opportunity to enter the BlackBerry Developer Challenge. See >>> full prize >>> details at: http://p.sf.net/sfu/Challenge >>> _______________________________________________ >>> Pyobjc-dev mailing list >>> Pyo...@li... >>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> > |
From: Dirk S. <dir...@ma...> - 2009-07-08 11:51:30
|
Hi Ronald, Thanks for this. No worries about taking a while to get to it, I'm very grateful. :) I'll check out r2261 to see if I can start using that revision (still on 2.2b2 right now) for Checkout. Looking at where the problem lies, this probably also fixes the problems I encountered with .new() before. Funny how those two issues seem to be related again. Thanks again, - Dirk On Jul 8, 2009, at 1:14 PM, Ronald Oussoren wrote: > Refcounts are annoying.... Actually understanding what was going > wrong was slightly harder than I had expected, but I managed to find > and fix the bug. > > The end of the output of your example when I close the window is now: > > 2009-07-08 13:05:24.955 TopLevelLeaker[71318:903] dealloc in > <TLWindowController: 0x104d46780> > 2009-07-08 13:05:24.957 TopLevelLeaker[71318:903] dealloc in > <TLPythonInitView: 0x104d49d50> > 2009-07-08 13:05:24.958 TopLevelLeaker[71318:903] dealloc in > <TLVanillaArrayController: 0x104f71b40>[object class: > NSMutableDictionary, number of selected objects: 0] > 2009-07-08 13:05:24.959 TopLevelLeaker[71318:903] dealloc in > <TLVanillaView: 0x104f76140> > 2009-07-08 13:05:24.961 TopLevelLeaker[71318:903] dealloc called in > <TLPythonInitArrayController: 0x104f72110>[object class: > NSMutableDictionary, number of selected objects: 0] > > As you can see the program now correctly deallocs both the > PythonInitView and the VanillaView. > > I've committed the fix as r2261. This is however a partial commit > from my working tree, I'm pretty sure I included just the right > amount of changes to truly fix the issue. I cannot do a full commit > at the moment because my working tree contains SnowLeopard-related > code which cannot be released because SL is under NDA. > > Ronald > > On 8 Jul, 2009, at 11:35, Ronald Oussoren wrote: > >> Dirk, >> >> Sorry about the slow response, it's busy at work and haven't been >> able >> to find time to dive into this until now. >> >> The good news is that this issue is unrelated to NIB files, making it >> a lot easier to debug than I feared that it would be. The bad news is >> that there seems to be a serious memory leak in PyObjC when instances >> are created in ObjC code but have a Python initializer. >> >> I currently have a testcase with some ObjC code that calls [[cls >> alloc] init] on an arbitrary class. When I create an object using >> this >> code in class that has a Python init method, the instance is never >> released. When the (Python) class does not have a Python init method >> it will be released. >> >> Now that I have a pretty simple testcase that reproduces the issue >> I'm >> hopeful that I'll be able to fix the issue soon, and keep it fixed. >> The failure mode also points to a fairly specific path through the >> code, which should help in pinpointing the issue. >> >> BTW. This does not affect creating new instances from Python code, >> which is probably why this is only really noticable in some specific >> contexts. >> >> Ronald >> >> On 23 Jun, 2009, at 14:52, Dirk Stoop wrote: >> >>> Hi Ronald, >>> >>> A sample app that demonstrates the isolated issue is attached. See >>> the README.txt in the archive for a quick overview. >>> >>> <TopLevelLeaker.zip> >>> >>> Cheers, >>> -Dirk >>> >>> On Jun 23, 2009, at 10:55 AM, Ronald Oussoren wrote: >>> >>>> Dirk, >>>> >>>> On 23 Jun, 2009, at 10:32, Dirk Stoop wrote: >>>> >>>>> Hi Ronald, >>>>> >>>>> I use objc.IBOutlet() all over the place, so I've tried a couple >>>>> of >>>>> things. >>>> >>>> I just thought of an easier way to do this: before importing any >>>> PyObjC classes do: import objc; objc.IBOutlet = objc.ivar. I wonder >>>> why I didn't think of that earlier :-( >>>> >>>>> >>>>> Short summary is: It definitely changes behavior, but it doesn't >>>>> solve the problem. >>>>> >>>>> I've tried the following things: >>>>> >>>>> 1. Add an objc.ivar() definition (with the same name) after an >>>>> outlet definition to a top-level object that has an init method >>>>> implemented in Python. >>>>> 2. Add an objc.ivar() definition (with the same name) after an >>>>> outlet definition to a top-level object that's a vanilla Cocoa >>>>> class. >>>>> 3. Add an objc.ivar() definition (again, the same name) after an >>>>> outlet definition to a non-top-level object that's implemented >>>>> with >>>>> Python, but doesn't override the designated initializer. >>>> >>>> Could you create a small application that demonstrates the problem? >>>> That would make testing on my side a lot easier. >>>> >>>> Ronald >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Are you an open source citizen? Join us for the Open Source Bridge >>>> conference! >>>> Portland, OR, June 17-19. Two days of sessions, one day of >>>> unconference: $250. >>>> Need another reason to go? 24-hour hacker lounge. Register today! >>>> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org >>>> _______________________________________________ >>>> Pyobjc-dev mailing list >>>> Pyo...@li... >>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >>> >>> ------------------------------------------------------------------------------ >>> Are you an open source citizen? Join us for the Open Source Bridge >>> conference! >>> Portland, OR, June 17-19. Two days of sessions, one day of >>> unconference: $250. >>> Need another reason to go? 24-hour hacker lounge. Register today! >>> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org_______________________________________________ >>> Pyobjc-dev mailing list >>> Pyo...@li... >>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> >> >> ------------------------------------------------------------------------------ >> Enter the BlackBerry Developer Challenge >> This is your chance to win up to $100,000 in prizes! For a limited >> time, >> vendors submitting new applications to BlackBerry App World(TM) >> will have >> the opportunity to enter the BlackBerry Developer Challenge. See >> full prize >> details at: http://p.sf.net/sfu/Challenge >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |
From: Ronald O. <ron...@ma...> - 2009-07-08 11:14:36
|
Refcounts are annoying.... Actually understanding what was going wrong was slightly harder than I had expected, but I managed to find and fix the bug. The end of the output of your example when I close the window is now: 2009-07-08 13:05:24.955 TopLevelLeaker[71318:903] dealloc in <TLWindowController: 0x104d46780> 2009-07-08 13:05:24.957 TopLevelLeaker[71318:903] dealloc in <TLPythonInitView: 0x104d49d50> 2009-07-08 13:05:24.958 TopLevelLeaker[71318:903] dealloc in <TLVanillaArrayController: 0x104f71b40>[object class: NSMutableDictionary, number of selected objects: 0] 2009-07-08 13:05:24.959 TopLevelLeaker[71318:903] dealloc in <TLVanillaView: 0x104f76140> 2009-07-08 13:05:24.961 TopLevelLeaker[71318:903] dealloc called in <TLPythonInitArrayController: 0x104f72110>[object class: NSMutableDictionary, number of selected objects: 0] As you can see the program now correctly deallocs both the PythonInitView and the VanillaView. I've committed the fix as r2261. This is however a partial commit from my working tree, I'm pretty sure I included just the right amount of changes to truly fix the issue. I cannot do a full commit at the moment because my working tree contains SnowLeopard-related code which cannot be released because SL is under NDA. Ronald On 8 Jul, 2009, at 11:35, Ronald Oussoren wrote: > Dirk, > > Sorry about the slow response, it's busy at work and haven't been able > to find time to dive into this until now. > > The good news is that this issue is unrelated to NIB files, making it > a lot easier to debug than I feared that it would be. The bad news is > that there seems to be a serious memory leak in PyObjC when instances > are created in ObjC code but have a Python initializer. > > I currently have a testcase with some ObjC code that calls [[cls > alloc] init] on an arbitrary class. When I create an object using this > code in class that has a Python init method, the instance is never > released. When the (Python) class does not have a Python init method > it will be released. > > Now that I have a pretty simple testcase that reproduces the issue I'm > hopeful that I'll be able to fix the issue soon, and keep it fixed. > The failure mode also points to a fairly specific path through the > code, which should help in pinpointing the issue. > > BTW. This does not affect creating new instances from Python code, > which is probably why this is only really noticable in some specific > contexts. > > Ronald > > On 23 Jun, 2009, at 14:52, Dirk Stoop wrote: > >> Hi Ronald, >> >> A sample app that demonstrates the isolated issue is attached. See >> the README.txt in the archive for a quick overview. >> >> <TopLevelLeaker.zip> >> >> Cheers, >> -Dirk >> >> On Jun 23, 2009, at 10:55 AM, Ronald Oussoren wrote: >> >>> Dirk, >>> >>> On 23 Jun, 2009, at 10:32, Dirk Stoop wrote: >>> >>>> Hi Ronald, >>>> >>>> I use objc.IBOutlet() all over the place, so I've tried a couple of >>>> things. >>> >>> I just thought of an easier way to do this: before importing any >>> PyObjC classes do: import objc; objc.IBOutlet = objc.ivar. I wonder >>> why I didn't think of that earlier :-( >>> >>>> >>>> Short summary is: It definitely changes behavior, but it doesn't >>>> solve the problem. >>>> >>>> I've tried the following things: >>>> >>>> 1. Add an objc.ivar() definition (with the same name) after an >>>> outlet definition to a top-level object that has an init method >>>> implemented in Python. >>>> 2. Add an objc.ivar() definition (with the same name) after an >>>> outlet definition to a top-level object that's a vanilla Cocoa >>>> class. >>>> 3. Add an objc.ivar() definition (again, the same name) after an >>>> outlet definition to a non-top-level object that's implemented with >>>> Python, but doesn't override the designated initializer. >>> >>> Could you create a small application that demonstrates the problem? >>> That would make testing on my side a lot easier. >>> >>> Ronald >>> >>> >>> ------------------------------------------------------------------------------ >>> Are you an open source citizen? Join us for the Open Source Bridge >>> conference! >>> Portland, OR, June 17-19. Two days of sessions, one day of >>> unconference: $250. >>> Need another reason to go? 24-hour hacker lounge. Register today! >>> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org >>> _______________________________________________ >>> Pyobjc-dev mailing list >>> Pyo...@li... >>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> >> ------------------------------------------------------------------------------ >> Are you an open source citizen? Join us for the Open Source Bridge >> conference! >> Portland, OR, June 17-19. Two days of sessions, one day of >> unconference: $250. >> Need another reason to go? 24-hour hacker lounge. Register today! >> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org_______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited > time, > vendors submitting new applications to BlackBerry App World(TM) will > have > the opportunity to enter the BlackBerry Developer Challenge. See > full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Ronald O. <ron...@ma...> - 2009-07-08 09:36:18
|
Dirk, Sorry about the slow response, it's busy at work and haven't been able to find time to dive into this until now. The good news is that this issue is unrelated to NIB files, making it a lot easier to debug than I feared that it would be. The bad news is that there seems to be a serious memory leak in PyObjC when instances are created in ObjC code but have a Python initializer. I currently have a testcase with some ObjC code that calls [[cls alloc] init] on an arbitrary class. When I create an object using this code in class that has a Python init method, the instance is never released. When the (Python) class does not have a Python init method it will be released. Now that I have a pretty simple testcase that reproduces the issue I'm hopeful that I'll be able to fix the issue soon, and keep it fixed. The failure mode also points to a fairly specific path through the code, which should help in pinpointing the issue. BTW. This does not affect creating new instances from Python code, which is probably why this is only really noticable in some specific contexts. Ronald On 23 Jun, 2009, at 14:52, Dirk Stoop wrote: > Hi Ronald, > > A sample app that demonstrates the isolated issue is attached. See > the README.txt in the archive for a quick overview. > > <TopLevelLeaker.zip> > > Cheers, > -Dirk > > On Jun 23, 2009, at 10:55 AM, Ronald Oussoren wrote: > >> Dirk, >> >> On 23 Jun, 2009, at 10:32, Dirk Stoop wrote: >> >>> Hi Ronald, >>> >>> I use objc.IBOutlet() all over the place, so I've tried a couple of >>> things. >> >> I just thought of an easier way to do this: before importing any >> PyObjC classes do: import objc; objc.IBOutlet = objc.ivar. I wonder >> why I didn't think of that earlier :-( >> >>> >>> Short summary is: It definitely changes behavior, but it doesn't >>> solve the problem. >>> >>> I've tried the following things: >>> >>> 1. Add an objc.ivar() definition (with the same name) after an >>> outlet definition to a top-level object that has an init method >>> implemented in Python. >>> 2. Add an objc.ivar() definition (with the same name) after an >>> outlet definition to a top-level object that's a vanilla Cocoa >>> class. >>> 3. Add an objc.ivar() definition (again, the same name) after an >>> outlet definition to a non-top-level object that's implemented with >>> Python, but doesn't override the designated initializer. >> >> Could you create a small application that demonstrates the problem? >> That would make testing on my side a lot easier. >> >> Ronald >> >> >> ------------------------------------------------------------------------------ >> Are you an open source citizen? Join us for the Open Source Bridge >> conference! >> Portland, OR, June 17-19. Two days of sessions, one day of >> unconference: $250. >> Need another reason to go? 24-hour hacker lounge. Register today! >> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > ------------------------------------------------------------------------------ > Are you an open source citizen? Join us for the Open Source Bridge > conference! > Portland, OR, June 17-19. Two days of sessions, one day of > unconference: $250. > Need another reason to go? 24-hour hacker lounge. Register today! > http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Ben A. <be...@ar...> - 2009-07-06 22:13:20
|
> Tried a simple interactive approach which did nothing. Is this > possible to do and if so what is the minimum necessary to do it? > > I tried: >>>> from Foundation import * > >>>> class O(NSObject): > ... def printNotif(self,notice): > ... print notice > >>>> nc = NSDistributedNotificationCenter.defaultCenter() >>>> nc.addObserver_selector_name_object_(o, o.printNotif, > "SomethingChanged", nil) > > and posted the notification from another python shell. Nothing > received. Runloop missing? Something else? If I recall correctly, you need a runloop, and you need to make sure that your observer doesn't go out of scope before you get the notification, because the DNC doesn't retain it. -- <http://artins.org/ben> "Calling computing 'computer science' is like calling surgery 'knife science'." -- Edsger Dijkstra |
From: Samantha A. <sja...@ma...> - 2009-07-06 21:52:32
|
Tried a simple interactive approach which did nothing. Is this possible to do and if so what is the minimum necessary to do it? I tried: >>> from Foundation import * >>> class O(NSObject): ... def printNotif(self,notice): ... print notice >>> nc = NSDistributedNotificationCenter.defaultCenter() >>> nc.addObserver_selector_name_object_(o, o.printNotif, "SomethingChanged", nil) and posted the notification from another python shell. Nothing received. Runloop missing? Something else? |
From: Ronald O. <ron...@ma...> - 2009-07-06 07:01:07
|
On 4 Jul, 2009, at 18:12, Ian Beck wrote: > Thanks, Dirk. I believe that's exactly what I need if I'm going to > figure out how to get this darn method working. I'd advise you to use "objc.registerMetaDataForSelector" option unless you have a lot more metadata to specify. The bridgesupport files are a slightly enhanced version of the files generated by gen_bridge_metadata (1), but sadly enough the PyObjC tools for creating and maintaining these files are more or less broken at the moment. Ronald > > Ian > > On Jul 4, 2009, at 6:07 AM, Dirk Stoop wrote: > >> Hi Ian, >> >> I'm not completely clear on the technical details of how >> BridgeSupport definitions are used in PyObjC, but here's some >> possible pointers: >> >> search for "withObjects" in the file linked below and you'll find >> the exceptions defined for NSArray.arrayWithObjects: and other >> similar methods: >>> http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-framework-Cocoa/Exceptions/Foundation.bridgesupport >> >> >> This test file shows how to explicitely add metadata to a class >> description at runtime: >>> http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-core/PyObjCTest/test_metadata_py.py >> >> >> The example at line 45 seems to do something similar to what you >> need: >> >> objc.registerMetaDataForSelector("OC_MetaDataTest", >> "makeObjectArray:on:", >> dict( >> arguments={ >> 2+0: dict(type_modifier=objc._C_IN, >> c_array_delimited_by_null=True, null_accepted=False), >> } >> ) >> ) >> >> Good luck :) >> - Dirk >> >> On Jul 3, 2009, at 4:40 AM, Ian Beck wrote: >> >>> Hey there, >>> >>> I'm currently loading up a custom Cocoa framework, and one of the >>> methods I need to call involves variable arguments terminated by >>> nil: >>> >>> [buildSomethingNamed:@"Name" withObjects:@"one", @"two", nil] >>> >>> I know that PyObjC typically has problems with varargs and needs a >>> special wrapper. Is there anything I can do at my end (that is, >>> outside the framework) to wrap this particular method and get it to >>> work with PyObjC? >>> >>> Even a pointer to somewhere to find example code for dealing with >>> varargs would be helpful; Google wasn't terribly useful. >>> >>> Ian >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> Pyobjc-dev mailing list >>> Pyo...@li... >>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> > > > ------------------------------------------------------------------------------ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Ronald O. <ron...@ma...> - 2009-07-06 06:57:12
|
On 4 Jul, 2009, at 17:13, Daniel Miller wrote: > I'm working on an application that I would like to continue to > deploy to OS X 10.4 Tiger. I recently upgraded my development box to > 10.5 Leopard (I know, coming late to the party here) and I'm > wondering what my options are for deploying the app to both Tiger > and Leopard? > > The app currently uses PyObjC 1.4 and is bundled into an app with > py2app. I'd like to upgrade to PyObjC 2 if possible. All development > up to this point has been done on Tiger. While the py2app-built > application at least launches on Leopard, many features appear to be > broken (drag/drop is deathly slow, animations are choppy, etc.). I'm > wondering if there is any hope of developing this app on Leopard > while continuing to deploy to Tiger? PyObjC 2 may or may not work on Tiger. I'm very limited in the amount of time I can spend on PyObjC, and as I don't need Tiger support myself Tiger support tends to end up late on the list. Ronald |
From: Ian B. <ia...@on...> - 2009-07-04 16:39:48
|
Thanks, Dirk. I believe that's exactly what I need if I'm going to figure out how to get this darn method working. Ian On Jul 4, 2009, at 6:07 AM, Dirk Stoop wrote: > Hi Ian, > > I'm not completely clear on the technical details of how > BridgeSupport definitions are used in PyObjC, but here's some > possible pointers: > > search for "withObjects" in the file linked below and you'll find > the exceptions defined for NSArray.arrayWithObjects: and other > similar methods: >> http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-framework-Cocoa/Exceptions/Foundation.bridgesupport > > > This test file shows how to explicitely add metadata to a class > description at runtime: >> http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-core/PyObjCTest/test_metadata_py.py > > > The example at line 45 seems to do something similar to what you need: > > objc.registerMetaDataForSelector("OC_MetaDataTest", > "makeObjectArray:on:", > dict( > arguments={ > 2+0: dict(type_modifier=objc._C_IN, > c_array_delimited_by_null=True, null_accepted=False), > } > ) > ) > > Good luck :) > - Dirk > > On Jul 3, 2009, at 4:40 AM, Ian Beck wrote: > >> Hey there, >> >> I'm currently loading up a custom Cocoa framework, and one of the >> methods I need to call involves variable arguments terminated by nil: >> >> [buildSomethingNamed:@"Name" withObjects:@"one", @"two", nil] >> >> I know that PyObjC typically has problems with varargs and needs a >> special wrapper. Is there anything I can do at my end (that is, >> outside the framework) to wrap this particular method and get it to >> work with PyObjC? >> >> Even a pointer to somewhere to find example code for dealing with >> varargs would be helpful; Google wasn't terribly useful. >> >> Ian >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |
From: Daniel M. <mil...@gm...> - 2009-07-04 15:14:18
|
I'm working on an application that I would like to continue to deploy to OS X 10.4 Tiger. I recently upgraded my development box to 10.5 Leopard (I know, coming late to the party here) and I'm wondering what my options are for deploying the app to both Tiger and Leopard? The app currently uses PyObjC 1.4 and is bundled into an app with py2app. I'd like to upgrade to PyObjC 2 if possible. All development up to this point has been done on Tiger. While the py2app-built application at least launches on Leopard, many features appear to be broken (drag/drop is deathly slow, animations are choppy, etc.). I'm wondering if there is any hope of developing this app on Leopard while continuing to deploy to Tiger? Thanks in advance for your insight and answers. ~ Daniel |
From: Dirk S. <dir...@ma...> - 2009-07-04 13:07:09
|
Hi Ian, I'm not completely clear on the technical details of how BridgeSupport definitions are used in PyObjC, but here's some possible pointers: search for "withObjects" in the file linked below and you'll find the exceptions defined for NSArray.arrayWithObjects: and other similar methods: > http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-framework-Cocoa/Exceptions/Foundation.bridgesupport This test file shows how to explicitely add metadata to a class description at runtime: > http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-core/PyObjCTest/test_metadata_py.py The example at line 45 seems to do something similar to what you need: objc.registerMetaDataForSelector("OC_MetaDataTest", "makeObjectArray:on:", dict( arguments={ 2+0: dict(type_modifier=objc._C_IN, c_array_delimited_by_null=True, null_accepted=False), } ) ) Good luck :) - Dirk On Jul 3, 2009, at 4:40 AM, Ian Beck wrote: > Hey there, > > I'm currently loading up a custom Cocoa framework, and one of the > methods I need to call involves variable arguments terminated by nil: > > [buildSomethingNamed:@"Name" withObjects:@"one", @"two", nil] > > I know that PyObjC typically has problems with varargs and needs a > special wrapper. Is there anything I can do at my end (that is, > outside the framework) to wrap this particular method and get it to > work with PyObjC? > > Even a pointer to somewhere to find example code for dealing with > varargs would be helpful; Google wasn't terribly useful. > > Ian > > ------------------------------------------------------------------------------ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Ian B. <ia...@on...> - 2009-07-03 03:05:37
|
Hey there, I'm currently loading up a custom Cocoa framework, and one of the methods I need to call involves variable arguments terminated by nil: [buildSomethingNamed:@"Name" withObjects:@"one", @"two", nil] I know that PyObjC typically has problems with varargs and needs a special wrapper. Is there anything I can do at my end (that is, outside the framework) to wrap this particular method and get it to work with PyObjC? Even a pointer to somewhere to find example code for dealing with varargs would be helpful; Google wasn't terribly useful. Ian |
From: Ronald O. <ron...@ma...> - 2009-06-30 11:34:34
|
On 26 Jun, 2009, at 16:05, Ian Beck wrote: > Hey there, > > One of my users messaged me to let me know that my Cocoa plugin > (written in Python using PyObjC with py2app) was failing to load on > his machine. Turns out he was using PyObjC 2.2 beta 2, and it was > dying because it wasn't handling an implicit **NSError argument. > Here's the relevant Python code that was killing it: > > @objc.signature('B@:@') > def performActionWithContext_error_(self, context): > > This function is defined by the program's protocol: > > - (BOOL)performActionWithContext:(id)context error:(NSError **) > outError; > > Is PyObjC 2.2 no longer going to silently support **NSError > parameters, or is this a known 2.2 bug? In PyObjC 2.2 you have to specify all arguments that the ObjC method gets, that includes output arguments like NSError. There are two reasons for that: first of all this makes the interface more regular and easier to learn, more importantly this enables new functionality: you can now detect if the user wants the value (outError is None) or not (ourError is objc.NULL). Ronald |
From: Ronald O. <ron...@ma...> - 2009-06-30 09:54:58
|
On 30 Jun, 2009, at 0:38, Ratko Jagodic wrote: > I am trying to capture some mouse events using CGEventTapCreate and > I found out that the following causes a bus error every time: > > eventMask = (1<<kCGEventMouseMoved) > eventTap = CGEventTapCreate(kCGSessionEventTap, > kCGHeadInsertEventTap, 0, eventMask, myCGEventCallback) > > > I've traced it down to two problems, both in Quartz framework in > _callbacks.m in the function m_CGEventTapCreate: > > (1) the function expects 5 inputs and yet it tries to assign 6, last > one being "info"... which ends up being an uninitialized pointer. > That seems to cause a bus error further down when it tries to create > a tuple of "callback" and "info": > PyObject* real_info = Py_BuildValue("OO", > callback, info); > For my purposes, I just changed CGEventTapCreate to accept 6th input > when parsing arguments ("OOOOOO"), as it does in carbon. Not sure if > that's the right approach... > > > (2) After fixing that, I encountered the next bus error with the > line further down in the same function: > CFRelease(retval); > I have no idea why this is crashing but I just commented it out for > now. I am assuming the worst that can happen is a memory leak and > considering that I call this only once, I didn't think it was a big > problem. Thanks for the bugreport. > > > > Also, how does one compile svn trunk properly??? "easy_install > pyobjc" downloads a new version when I want it to compile my > modified version. Right now I have a serious hack... the whole 2.2b2 > from easy_install + Quartz compiled separately from svn (2.2b3). This should work just fine. Building the entire trunk is not very convenient at the moment, there is a script for rebuilding everything at the toplevel in the repository (that is, the directory that also contains pyobjc-core). This script runs 'python setup.py develop' on all subprojects. Ronald > > > Some system info: > Mac OS X 10.5.7 > Apple Python 2.5 > built-in PyObjC (also tried PyObjC 2.2b2) > > > -Ratko > ------------------------------------------------------------------------------ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Ratko J. <rja...@gm...> - 2009-06-29 22:39:43
|
I am trying to capture some mouse events using CGEventTapCreate and I found out that the following causes a bus error every time: eventMask = (1<<kCGEventMouseMoved) eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0, eventMask, myCGEventCallback) I've traced it down to two problems, both in Quartz framework in _callbacks.m in the function m_CGEventTapCreate: (1) the function expects 5 inputs and yet it tries to assign 6, last one being "info"... which ends up being an uninitialized pointer. That seems to cause a bus error further down when it tries to create a tuple of "callback" and "info": PyObject* real_info = Py_BuildValue("OO", callback, info); For my purposes, I just changed CGEventTapCreate to accept 6th input when parsing arguments ("OOOOOO"), as it does in carbon. Not sure if that's the right approach... (2) After fixing that, I encountered the next bus error with the line further down in the same function: CFRelease(retval); I have no idea why this is crashing but I just commented it out for now. I am assuming the worst that can happen is a memory leak and considering that I call this only once, I didn't think it was a big problem. Also, how does one compile svn trunk properly??? "easy_install pyobjc" downloads a new version when I want it to compile my modified version. Right now I have a serious hack... the whole 2.2b2 from easy_install + Quartz compiled separately from svn (2.2b3). Some system info:Mac OS X 10.5.7 Apple Python 2.5 built-in PyObjC (also tried PyObjC 2.2b2) -Ratko |
From: Ian B. <ia...@on...> - 2009-06-26 14:32:20
|
Hey there, One of my users messaged me to let me know that my Cocoa plugin (written in Python using PyObjC with py2app) was failing to load on his machine. Turns out he was using PyObjC 2.2 beta 2, and it was dying because it wasn't handling an implicit **NSError argument. Here's the relevant Python code that was killing it: @objc.signature('B@:@') def performActionWithContext_error_(self, context): This function is defined by the program's protocol: - (BOOL)performActionWithContext:(id)context error:(NSError **)outError; Is PyObjC 2.2 no longer going to silently support **NSError parameters, or is this a known 2.2 bug? Ian |
From: Dirk S. <dir...@ma...> - 2009-06-25 18:17:04
|
On Jun 25, 2009, at 5:01 PM, Ronald Oussoren wrote: > > 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: > Thanks, I'll switch that code over to the method you describe, sounds a lot cleaner. - Dirk > m = __import__(someClassName) > instance = getattr(m, someClassName).alloc().init() > > Ronald > >> >> - Dirk > |
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 |
From: Dirk S. <dir...@ma...> - 2009-06-25 14:39:05
|
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) - Dirk |
From: Ronald O. <ron...@ma...> - 2009-06-25 06:03:05
|
On 24 Jun, 2009, at 2:34, Dirk Stoop wrote: > > > Make sure you try making a release build of your project after setting > this up though, to verify that the .py file that contains your > QTMovieView subclass is actually bundled in the app. (I'm not sure if > the current Xcode support/templates in PyObjC still relies on > module_graph to detect what needs to be bundled and what not when > building an autonomous .app, but if it does, your module will not be > included if it's only imported in some class' instance or class > methods). The current Xcode templates don't use py2app at all, which really sucks but is unlikely to change soon because fixing that requires some refactoring in py2app. 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. Ronald > > Cheers, > - Dirk > > On Jun 16, 2009, at 5:19 PM, Orestis Markou wrote: > >> That's because at the time of the import (when main.m is executed) >> there's no connection to the window server yet. >> >> To get around this, you need to start importing in the >> 'applicationDidFinishLaunching' stage. If you want to subclass >> QTMovieView, put it in a different module, and import it in the >> delegate method. That probably means you can't use it in Interface >> Builder - you may be able to set it at runtime, but I can't help you >> there. >> -- >> or...@or... >> http://orestis.gr/ >> >> >> >> >> On 16 Jun 2009, at 18:13, Daniel Ashbrook wrote: >> >>> Does anybody have an idea on how I can deal with this? I got around >>> the issue back in April but now am wanting to subclass a >>> QTMovieView. >>> >>> Thanks, >>> >>> dan >>> >>> On Apr 27, 2009, at 12:25p, Daniel Ashbrook wrote: >>> >>>> I think I remember there being some discussion of this a while >>>> back, >>>> but couldn't find it. >>>> >>>> Try this: >>>> 1) Make a new Python Cocoa app in Xcode >>>> 2) In the application delegate, insert the line "import QTKit" >>>> 3) Run it >>>> >>>> I get: >>>> >>>> _RegisterApplication(), FAILED TO establish the default connection >>>> to the WindowServer, _CGSDefaultConnection() is NULL. >>>> 2009-04-27 12:22:41.794 QTVideoTest2[79402:10b] *** - >>>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>>> '(null)') unlocked when not locked >>>> 2009-04-27 12:22:41.796 QTVideoTest2[79402:10b] *** Break on >>>> _NSLockError() to debug. >>>> 2009-04-27 12:22:41.796 QTVideoTest2[79402:10b] *** - >>>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>>> '(null)') unlocked when not locked >>>> 2009-04-27 12:22:41.797 QTVideoTest2[79402:10b] *** Break on >>>> _NSLockError() to debug. >>>> 2009-04-27 12:22:41.801 QTVideoTest2[79402:10b] *** - >>>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>>> '(null)') unlocked when not locked >>>> 2009-04-27 12:22:41.801 QTVideoTest2[79402:10b] *** Break on >>>> _NSLockError() to debug. >>>> 2009-04-27 12:22:41.804 QTVideoTest2[79402:10b] >>>> NSInternalInconsistencyException - Error (1002) creating CGSWindow >>>> 2009-04-27 12:22:41.811 QTVideoTest2[79402:10b] *** - >>>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>>> '(null)') unlocked when not locked >>>> 2009-04-27 12:22:41.812 QTVideoTest2[79402:10b] *** Break on >>>> _NSLockError() to debug. >>>> 2009-04-27 12:22:41.812 QTVideoTest2[79402:10b] *** - >>>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>>> '(null)') unlocked when not locked >>>> 2009-04-27 12:22:41.812 QTVideoTest2[79402:10b] *** Break on >>>> _NSLockError() to debug. >>>> 2009-04-27 12:22:41.813 QTVideoTest2[79402:10b] *** - >>>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>>> '(null)') unlocked when not locked >>>> 2009-04-27 12:22:41.813 QTVideoTest2[79402:10b] *** Break on >>>> _NSLockError() to debug. >>>> 2009-04-27 12:22:41.814 QTVideoTest2[79402:10b] *** - >>>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>>> '(null)') unlocked when not locked >>>> 2009-04-27 12:22:41.815 QTVideoTest2[79402:10b] *** Break on >>>> _NSLockError() to debug. >>>> >>>> This is particularly frustrating as, in my real project, I am >>>> trying >>>> to make a subclass of QTKit.QTCaptureView; however, I can't, as >>>> importing yields the above errors. >>>> >>>> >>>> dan >>> >>> >>> ------------------------------------------------------------------------------ >>> Crystal Reports - New Free Runtime and 30 Day Trial >>> Check out the new simplified licensing option that enables unlimited >>> royalty-free distribution of the report engine for externally facing >>> server and web deployment. >>> http://p.sf.net/sfu/businessobjects >>> _______________________________________________ >>> Pyobjc-dev mailing list >>> Pyo...@li... >>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >> >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables unlimited >> royalty-free distribution of the report engine for externally facing >> server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > ------------------------------------------------------------------------------ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Dirk S. <dir...@ma...> - 2009-06-24 01:01:06
|
(@Orestis: I Forgot to hit 'Reply All', so sorry if you're getting this twice) Actualy, if you do this, you *will* be able to use it in Interface Builder. The only requirement is that the class is loaded/imported before the nib is initialized. So if you, for instance, use an instance of your QTMovieView subclass in a nib owned by a specific windowController or viewController, import the QTMovieView subclass' module in the header of the controller's source file (if the controller is imported lazily), or otherwise, import it in the designated initializer of the controller (if you don't import the controller lazily, which is the more likely approach). Your QTMovieView subclass should instantiate fine as long as it is imported some time before the nib loads. Make sure you try making a release build of your project after setting this up though, to verify that the .py file that contains your QTMovieView subclass is actually bundled in the app. (I'm not sure if the current Xcode support/templates in PyObjC still relies on module_graph to detect what needs to be bundled and what not when building an autonomous .app, but if it does, your module will not be included if it's only imported in some class' instance or class methods). Cheers, - Dirk On Jun 16, 2009, at 5:19 PM, Orestis Markou wrote: > That's because at the time of the import (when main.m is executed) > there's no connection to the window server yet. > > To get around this, you need to start importing in the > 'applicationDidFinishLaunching' stage. If you want to subclass > QTMovieView, put it in a different module, and import it in the > delegate method. That probably means you can't use it in Interface > Builder - you may be able to set it at runtime, but I can't help you > there. > -- > or...@or... > http://orestis.gr/ > > > > > On 16 Jun 2009, at 18:13, Daniel Ashbrook wrote: > >> Does anybody have an idea on how I can deal with this? I got around >> the issue back in April but now am wanting to subclass a QTMovieView. >> >> Thanks, >> >> dan >> >> On Apr 27, 2009, at 12:25p, Daniel Ashbrook wrote: >> >>> I think I remember there being some discussion of this a while back, >>> but couldn't find it. >>> >>> Try this: >>> 1) Make a new Python Cocoa app in Xcode >>> 2) In the application delegate, insert the line "import QTKit" >>> 3) Run it >>> >>> I get: >>> >>> _RegisterApplication(), FAILED TO establish the default connection >>> to the WindowServer, _CGSDefaultConnection() is NULL. >>> 2009-04-27 12:22:41.794 QTVideoTest2[79402:10b] *** - >>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>> '(null)') unlocked when not locked >>> 2009-04-27 12:22:41.796 QTVideoTest2[79402:10b] *** Break on >>> _NSLockError() to debug. >>> 2009-04-27 12:22:41.796 QTVideoTest2[79402:10b] *** - >>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>> '(null)') unlocked when not locked >>> 2009-04-27 12:22:41.797 QTVideoTest2[79402:10b] *** Break on >>> _NSLockError() to debug. >>> 2009-04-27 12:22:41.801 QTVideoTest2[79402:10b] *** - >>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>> '(null)') unlocked when not locked >>> 2009-04-27 12:22:41.801 QTVideoTest2[79402:10b] *** Break on >>> _NSLockError() to debug. >>> 2009-04-27 12:22:41.804 QTVideoTest2[79402:10b] >>> NSInternalInconsistencyException - Error (1002) creating CGSWindow >>> 2009-04-27 12:22:41.811 QTVideoTest2[79402:10b] *** - >>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>> '(null)') unlocked when not locked >>> 2009-04-27 12:22:41.812 QTVideoTest2[79402:10b] *** Break on >>> _NSLockError() to debug. >>> 2009-04-27 12:22:41.812 QTVideoTest2[79402:10b] *** - >>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>> '(null)') unlocked when not locked >>> 2009-04-27 12:22:41.812 QTVideoTest2[79402:10b] *** Break on >>> _NSLockError() to debug. >>> 2009-04-27 12:22:41.813 QTVideoTest2[79402:10b] *** - >>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>> '(null)') unlocked when not locked >>> 2009-04-27 12:22:41.813 QTVideoTest2[79402:10b] *** Break on >>> _NSLockError() to debug. >>> 2009-04-27 12:22:41.814 QTVideoTest2[79402:10b] *** - >>> [NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x1c57730> >>> '(null)') unlocked when not locked >>> 2009-04-27 12:22:41.815 QTVideoTest2[79402:10b] *** Break on >>> _NSLockError() to debug. >>> >>> This is particularly frustrating as, in my real project, I am trying >>> to make a subclass of QTKit.QTCaptureView; however, I can't, as >>> importing yields the above errors. >>> >>> >>> dan >> >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables unlimited >> royalty-free distribution of the report engine for externally facing >> server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |