pyobjc-dev Mailing List for PyObjC (Page 18)
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: Marc A. <msa...@gm...> - 2012-06-21 20:51:07
|
I noticed that pyobjc-core isn't installable with pip, but it's installable with python setup.py install. Here's what I get with `pip install .`: https://gist.github.com/2968422 This seems to have something to do with pyobjc-core's setup.py. I got `pip install .` to work as follows: ``` (env)[last: 0] marca@SCML-MarcA:~/dev/svn-repos/pyobjc-core$ curl -sk https://raw.github.com/gist/2968084/d4f1d538130c12023cfaac8d777f299f9e77f944/pyobjc-core-1.patch | patch patching file setup.py (env)[last: 0] marca@SCML-MarcA:~/dev/svn-repos/pyobjc-core$ pip install . Unpacking /Users/marca/dev/svn-repos/pyobjc-core Running setup.py egg_info for package from file:///Users/marca/dev/svn-repos/pyobjc-core ... Successfully installed pyobjc-core Cleaning up... ``` Hopefully the patch doesn't break anything else, but even if it does, at least it's a start at pinpointing what the problem is. Marc |
From: Daniel S. <dan...@gm...> - 2012-06-19 19:04:20
|
If you don't want to use Xcode, you can take a look at http://www.underbunch.org . there is a post there about setting up PyObjC without Xcode. Hope it helps. Cheers Daniel Santos On Jun 13, 2012, at 5:38 PM, tanya wrote: > Hello. I am just beginning with PyObjC, and so I downloaded XCode/ > PyObjC templates from http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/ > . Without changing anything I am running Instruments, and seeing > that there are leaks in XCode 4.3 (https://dl.dropbox.com/u/16876271/Screen%20Shot%202012-06-13%20at%2011.22.26%20AM.png > ). I also downloaded other templates based on that (https://github.com/gregneagle/Xcode4CocoaPythonTemplates > ), and these also leak. What can I do to resolve this? Is it too > minor to worry about? > > Thanks for your help! > > -t > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. > Discussions > will include endpoint security, mobile security and the latest in > malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: SourceForge.net <no...@so...> - 2012-06-19 16:51:30
|
Bugs item #3536370, was opened at 2012-06-19 09:51 Message generated for change (Tracker Item Submitted) made by sbronson You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=114534&aid=3536370&group_id=14534 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Samuel Bronson (sbronson) Assigned to: Nobody/Anonymous (nobody) Summary: Missing doc: Notes on supported APIs and classes on Mac OS X Initial Comment: The document "Notes on supported APIs and classes on Mac OS X" <http://pyobjc.sourceforge.net/documentation/pyobjc-core/api-notes-macosx.html>, referenced several times from "An introduction to PyObjC" <http://pyobjc.sourceforge.net/documentation/pyobjc-core/intro.html>, seems to have gone missing. Please find it! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=114534&aid=3536370&group_id=14534 |
From: Ronald O. <ron...@ma...> - 2012-06-15 02:52:32
|
On 13 Jun, 2012, at 2:22, Ken Thomases wrote: > I can't claim to follow all of the details of how PyObjC works, but here are my impressions: > > On Jun 12, 2012, at 10:13 AM, Ronald Oussoren wrote: > >> trim_chars = u"*" >> #trim_chars = Cocoa.CFStringCreateWithCString(None, trim_chars, Cocoa.kCFStringEncodingASCII) >> >> Cocoa.CFStringTrim(s, trim_chars) > > Here, there are two paths, depending on whether that line above is commented out. Either a unicode object is implicitly converted to a CFString/NSString or a it's an objc.pyobjc_unicode object wrapping what's already a CFString/NSString. What are the code paths used by the two cases? A lot of it is implicit and I'm not able to follow it. Case 1: trim_chars = u"" -> CFStringTrim's second argument is a Python unicode which is proxied as a OC_PythonUnicode object and that proxy is passed to the C function Case 2: trim_chars = Cocoa.CFString... -> CFStringTrim's second argument is an instance of pyobjc_unicode, and the embedded NSString* value is passed to the C function pyobjc_unicode is used to proxy an Objective-C string to Python. I'd prefer to not use a custom class for that, but that would increase friction: you'd have to explicitly convert NSString instances to a python unicode object when using numerous Python APIs implemented in C. Pyobjc_unicode shouldn't really be an issue for this problem though, the only instance of that class in the script is the instance of "s", and that's released as soon as "s.nsstring()" is called. > >> For me te problem only occurs when I run this code with a 64-bit build of python ("arch -x86_64 python2.7 ...") and works fine in a 32-bit build ("arch -i386 python2.7 ..."). I have only tested on OSX 10.7, I'm currently traveling and cannot easily test on other releases. To make life even more interesting, the problem only occurs when "PyObjC_UNICODE_FAST_PATH" is active. > > I note that PyObjC_UNICODE_FAST_PATH affects PyObjCUnicode_New() as well as the implementation of OC_PythonUnicode. I recommend that, instead of disabling it globally by tweaking the header, you disable it in each translation unit independently to isolate which is the problem. I'm sort of suspecting it's PyObjCUnicode_New() rather than OC_PythonUnicode, especially given that you tried disabling the implementation of -getCharacters:range:. I've in effect disabled PyObjC_UNICODE_FAST_PATH for OC_PythonUnicode at least for now, and that fixes the issue as well. PyObjCUnicode_New should be in the clear. My new implementation for OC_PythonUnicode always uses the __realObject__ trick, and only optimzes the implementation of __realObject__: when sizeof(unichar) == sizeof(Py_UNICODE) I create the NSString with the "NoCopy" variant of the NSString initializer. This avoids duplicating the string contents, although there's still the unnecessary object that eats more memory. I'll probably revisit this in the future, I'd prefer to get rid of the additional object where possible. For now my current implementation works, and there are more important things to work on right now (not in the least getting an actual release out). > > I also note that PyObjCUnicode_New() uses the deprecated method -getCharacters: (no range) when the Unicode fast path is enabled. Other than that, I see no obvious problems with either code. Good catch. This should be harmless, but -getCharacters:range: is saver. I'll update the code. > > Given the 32-/64-bit difference, I was for a while suspecting that Py_UNICODE might be 4-byte UCS32 under 64-bit, but I see that PyObjC_UNICODE_FAST_PATH would not be enabled in that case. *shrug* Luckily the size of Py_UNICODE is a configure-time constant, and 16 bits in the default builds of Python. In Python 3.3 and later Py_UNICODE is UCS4 unconditionally, and Python's unicode object then uses UCS1, UCS2 or UCS4 as the backing store as appropriate. And after some optimization Python 3.3 unicode string is now as memory efficient and fast as Python 2.7's byte string for most code (according to discussions on python-dev, I haven't done benchmarking myself). Anyway, thanks for your help. I've also talked to an Apple engineer at WWDC, and the custom NSString subclass should just work, I was at one point worrying that CFString's APIs weren't guaranteed to work with custom NSString subclasses. Ronald |
From: tanya <tok...@gm...> - 2012-06-14 17:39:00
|
In Instruments if I take a snapshot every sec, I get a list of leaked objects, they're either all Malloc or NSAutorelease Pool. When I follow memory addresses, I see "responsible callers": PyMem_Malloc or [NSAutoreleasePool allocWithZone]. -t On Wed, Jun 13, 2012 at 7:53 PM, Ronald Oussoren <ron...@ma...>wrote: > > On 13 Jun, 2012, at 9:38, tanya wrote: > > Hello. I am just beginning with PyObjC, and so I downloaded XCode/PyObjC > templates from http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/ . > Without changing anything I am running Instruments, and seeing that there > are leaks in XCode 4.3 ( > https://dl.dropbox.com/u/16876271/Screen%20Shot%202012-06-13%20at%2011.22.26%20AM.png). > I also downloaded other templates based on that ( > https://github.com/gregneagle/Xcode4CocoaPythonTemplates), and these also > leak. What can I do to resolve this? Is it too minor to worry about? > > > I don't use the Xcode templates myself (I'm an command-line nerd and use > vim and py2app instead). The leaks are probably not relevant, what does > Xcode say about the source of these leaks? If you select the leak > Instruments should tell you where the memory was allocated, and that might > tell us what's going on here. > > Ronald > > > Thanks for your help! > > -t > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > |
From: Ronald O. <ron...@ma...> - 2012-06-14 00:54:13
|
On 13 Jun, 2012, at 9:38, tanya wrote: > Hello. I am just beginning with PyObjC, and so I downloaded XCode/PyObjC templates from http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/ . Without changing anything I am running Instruments, and seeing that there are leaks in XCode 4.3 (https://dl.dropbox.com/u/16876271/Screen%20Shot%202012-06-13%20at%2011.22.26%20AM.png). I also downloaded other templates based on that (https://github.com/gregneagle/Xcode4CocoaPythonTemplates), and these also leak. What can I do to resolve this? Is it too minor to worry about? I don't use the Xcode templates myself (I'm an command-line nerd and use vim and py2app instead). The leaks are probably not relevant, what does Xcode say about the source of these leaks? If you select the leak Instruments should tell you where the memory was allocated, and that might tell us what's going on here. Ronald > > Thanks for your help! > > -t > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: tanya <tok...@gm...> - 2012-06-13 16:39:07
|
Hello. I am just beginning with PyObjC, and so I downloaded XCode/PyObjC templates from http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/ . Without changing anything I am running Instruments, and seeing that there are leaks in XCode 4.3 ( https://dl.dropbox.com/u/16876271/Screen%20Shot%202012-06-13%20at%2011.22.26%20AM.png). I also downloaded other templates based on that ( https://github.com/gregneagle/Xcode4CocoaPythonTemplates), and these also leak. What can I do to resolve this? Is it too minor to worry about? Thanks for your help! -t |
From: Ken T. <ke...@co...> - 2012-06-13 09:23:07
|
I can't claim to follow all of the details of how PyObjC works, but here are my impressions: On Jun 12, 2012, at 10:13 AM, Ronald Oussoren wrote: > trim_chars = u"*" > #trim_chars = Cocoa.CFStringCreateWithCString(None, trim_chars, Cocoa.kCFStringEncodingASCII) > > Cocoa.CFStringTrim(s, trim_chars) Here, there are two paths, depending on whether that line above is commented out. Either a unicode object is implicitly converted to a CFString/NSString or a it's an objc.pyobjc_unicode object wrapping what's already a CFString/NSString. What are the code paths used by the two cases? A lot of it is implicit and I'm not able to follow it. > For me te problem only occurs when I run this code with a 64-bit build of python ("arch -x86_64 python2.7 ...") and works fine in a 32-bit build ("arch -i386 python2.7 ..."). I have only tested on OSX 10.7, I'm currently traveling and cannot easily test on other releases. To make life even more interesting, the problem only occurs when "PyObjC_UNICODE_FAST_PATH" is active. I note that PyObjC_UNICODE_FAST_PATH affects PyObjCUnicode_New() as well as the implementation of OC_PythonUnicode. I recommend that, instead of disabling it globally by tweaking the header, you disable it in each translation unit independently to isolate which is the problem. I'm sort of suspecting it's PyObjCUnicode_New() rather than OC_PythonUnicode, especially given that you tried disabling the implementation of -getCharacters:range:. I also note that PyObjCUnicode_New() uses the deprecated method -getCharacters: (no range) when the Unicode fast path is enabled. Other than that, I see no obvious problems with either code. Given the 32-/64-bit difference, I was for a while suspecting that Py_UNICODE might be 4-byte UCS32 under 64-bit, but I see that PyObjC_UNICODE_FAST_PATH would not be enabled in that case. *shrug* Regards, Ken |
From: Ronald O. <ron...@ma...> - 2012-06-12 15:13:41
|
Hi, I'm running into an odd failure in the PyObjC test suite that is probably caused by a bug in OC_PythonUnicode in the pyobjc-core project. The relevant code looks fine though, and I have no idea what's going on here and would really appriciate if someone that knows Objective-C (and the Python C API) could have a look at the code. In particular, with the following script: <quote> import Cocoa # Create Cocoa string: s = Cocoa.CFStringCreateMutableCopy(None, 0, b"****foobar****".decode('ascii')) # Use this as a Cocoa object, instead of using the unicode subclass that's by default used for wrapping s = s.nsstring() trim_chars = u"*" #trim_chars = Cocoa.CFStringCreateWithCString(None, trim_chars, Cocoa.kCFStringEncodingASCII) Cocoa.CFStringTrim(s, trim_chars) print (s) </quote> This script prints an unexpected value (the "*" characters are not stripped on both sides), but works fine when the line that translates trim_chars in a Cocoa string is activated. For me te problem only occurs when I run this code with a 64-bit build of python ("arch -x86_64 python2.7 ...") and works fine in a 32-bit build ("arch -i386 python2.7 ..."). I have only tested on OSX 10.7, I'm currently traveling and cannot easily test on other releases. To make life even more interesting, the problem only occurs when "PyObjC_UNICODE_FAST_PATH" is active. It is best to use the version of PyObjC that is in my bitbucket repository to reproduce the problem (http://bitbucket.org/ronaldoussoren/pyobjc). You will have to change Modules/objc/pyobjc.h, I have for now disabled PyObjC_UNICODE_FAST_PATH unconditionally to avoid this problem. The relevant, failing, code is in Modules/objc/OC_PythonUnicode.m. This is a subclass of NSString that is used to proxy Python unicode strings into the Objective-C world. I've already tried disabling the implementation of "-getCharacters:range" and that didn't help. Ronald |
From: Ender <end...@gm...> - 2012-06-12 08:06:37
|
Hi, everybody. I put the source code of the PyObjC application that takes photos (and uploads them on Google Picasa) at http://code.google.com/p/icam-mobile-revival/ (also at http://go.to/slog). I would be happy to answer questions related to the project and collaborate with you to improve it. Best regards. Alex On 7/11/2011 6:58 AM, end...@gm... wrote: > Hi. > I'd like to inform you that I was finally able to access the camera and take photo > programatically. > Let me know if you are interested in more details. > > I will post a working port of my iCam project written in PyObjC, relying on this > module, at http://mobile-revival.110mb.com/ReVival/ (alias http://go.to/slog) in the > following days. > iCam is a cross platform video surveillance application using camera phones that I worked > on for more than 1 year. > The project transforms a mobile phone in a surveillance camera with motion detection. > One can also create a network of such devices connected via Bluetooth or WiFi, where > the master phone transmits via 3G/GSM. The photo/video > information can be uploaded on YouTube, Picasa, etc. > The phone application can be controlled remotely via Internet. > This project is deployed and in use for almost 1 year. > Best regards. > > On Thu, Jun 30, 2011 at 1:48 AM, <end...@gm... <mailto:end...@gm...>> wrote: > > Hi. > I am trying to implement in PyObjC the program available at > https://github.com/erica/iphone-3.0-cookbook-/tree/b8ca8905d17015839a0917e1dcd407d055890236/C07-Images/04-Snapping%20Images > . > > Although I am a "beginner" in PyObjC, I spent a couple of days trying to very > seriously translate this script to PyObjC and tried my best to find out all errors. > However, it doesn't work: the application doesn't execute normally after entering > viewDidLoad() - it doesn't change appearance of UI as specified there. I guess it has > to do with the fact I am not loading (or using the specification) of the > TestBedViewController.xib file, which describes properties of TestBedViewController - > I translated only the main.m and did not use by any means the > TestBedViewController.xib - I do not know how can I load this file in PyObjC on iOS... > Please find the PyObjC code I wrote so far here: > http://mobile-revival.110mb.com/ReVival/HelloPython.py . > > I run my PyObjC scripts on iOS version 3.1.2. PyObjC is version 1946-4, Python is > version 2.5.1-5 (obtained with Cydia 1.1.1; and libffi is version 130618-4). > > Best regards. > Alex > > |
From: Ronald O. <ron...@ma...> - 2012-05-23 06:04:05
|
On 21 May, 2012, at 12:54, Vincent wrote: > Hi Ronald, > > thanks for your quick answer! > > The former actually sounds like exactly what I'd need. > Just one more question: Given that my python script is stored inside an NSString property, > what actions/functions would would I need to run before being able to instantiate one of the python clases? > After all the Python would have to have been run before I'd be be able to instantiate one of its subclasses, no? You have to use the Python C API to initialize the interpreter and load a script file that creates the Python class. As an alternative you could create a plugin API and use py2app to create a plugin bundle, as described in <http://pyobjc.sourceforge.net/documentation/pyobjc-core/tutorial_embed/index.html>. > > Would something like this be the right way? > > #import <Python.h> > > … > > @protocol PythonClassProtocol > @optional > - (BOOL)shallRejectObject:(NSObject *)object; > @end > > … > > Py_Initialize(); > PyRun_SimpleString([self.script UTF8String]) > Py_Finalize(); > > id<PythonClassProtocol> pythonObject = [[NSClassFromString(@"PythonClass") alloc] init]; > > for (id<PythonClassProtocol> object in self.objects) { > if ([pythonObject shallRejectObject:object]) { > [self rejectObject:object]; > } > } This should work, but you shouldn't call Py_Finalize. > > Oh and what if the user (me) runs the Python script once, edits it and runs it again? Reloading scripts is a problem when the script defines a Objective-C class because redefining ObjC classes is something the ObjC runtime doesn't like. You could use the Python C API to create a new module for the script and use PyObject_GetAttrString(mod, "functionName") to access the callback functions. This makes it hard to forward ObjC objects to the callback function though. What probably works it another layer of indirection: create two python scripts, one of them contains the class definition with not only the -shallRejectObject: method, but also a method for loading a script. That way you can use the implict conversion of ObjC objects to Python provided by PyObjC, and use the Python class to forward the method calls to Python functions in the script: class PythonClass (NSObject, objc.protocolNamed("PythonClassProtocol")): def loadScript_(self, scriptText): self.symbols = {} exec(scriptText, self.symbols) def shallRejectObject_(self, object): return self.symbols["shallRejectObject")(object) This code is completely untested. > Any conflicts to be expected, given that a class of that name (with potentially different logic, of which I'd obviously want to use the new one) has been created before? > If the latter was the case would I have to extract my filtering routine (not just the filtering method, but the entire code as seen above) into > its own NSTask being re-launched on every execution and talk to my own app via some kind of bridge of my own (Distributed Objects, what not)? That would also work, but has a lot more overhead due to the interprocess communication. Ronald > > Thanks a bunch, > Vincent > > On May 21, 2012, at 8:02 AM, Ronald Oussoren wrote: > >> Using Python from ObjC like this is suboptimal at the moment, mostly because I don't use PyObjC in that way. I'd define an stub class with the right interface in Objective-C with a subclass in Python that implements that interface. That way you can fetch the Python class using objc_lookUpClass (or the Foundation wrapper around that function), create an instance and then call the methods without getting compiler warnings. >> >> To expose instances you have to define an API to fetch those instances. >> >> Ronald > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Vincent <mai...@sa...> - 2012-05-21 10:54:59
|
Hi Ronald, thanks for your quick answer! The former actually sounds like exactly what I'd need. Just one more question: Given that my python script is stored inside an NSString property, what actions/functions would would I need to run before being able to instantiate one of the python clases? After all the Python would have to have been run before I'd be be able to instantiate one of its subclasses, no? Would something like this be the right way? #import <Python.h> … @protocol PythonClassProtocol @optional - (BOOL)shallRejectObject:(NSObject *)object; @end … Py_Initialize(); PyRun_SimpleString([self.script UTF8String]) Py_Finalize(); id<PythonClassProtocol> pythonObject = [[NSClassFromString(@"PythonClass") alloc] init]; for (id<PythonClassProtocol> object in self.objects) { if ([pythonObject shallRejectObject:object]) { [self rejectObject:object]; } } Oh and what if the user (me) runs the Python script once, edits it and runs it again? Any conflicts to be expected, given that a class of that name (with potentially different logic, of which I'd obviously want to use the new one) has been created before? If the latter was the case would I have to extract my filtering routine (not just the filtering method, but the entire code as seen above) into its own NSTask being re-launched on every execution and talk to my own app via some kind of bridge of my own (Distributed Objects, what not)? Thanks a bunch, Vincent On May 21, 2012, at 8:02 AM, Ronald Oussoren wrote: > Using Python from ObjC like this is suboptimal at the moment, mostly because I don't use PyObjC in that way. I'd define an stub class with the right interface in Objective-C with a subclass in Python that implements that interface. That way you can fetch the Python class using objc_lookUpClass (or the Foundation wrapper around that function), create an instance and then call the methods without getting compiler warnings. > > To expose instances you have to define an API to fetch those instances. > > Ronald |
From: Ronald O. <ron...@ma...> - 2012-05-21 06:02:53
|
On 20 May, 2012, at 22:12, Vincent wrote: > Hi there, > > I'm new the whole PyObjC thing and have a simple document-bases app for which my goal is to all the user (personal project, so actually just me :P) to provide his/her (my) own filtering logic on a per-document basis. > > I basically have an NSSet of objects which need to be filtered based on a user-provided logic. > As the logic should not be limited to rather primitive NSPredicates I'd like to provide a barebones in-app Python editor in which the user can define his/her logic. > >> From what I've found on the web so far I know that one can subclass one's own Objective-C classes from inside Python using "objc.lookUpClass(…)". > There is however still one question that remained unanswered: > Being able to instantiate an Objective-C object from Python is neat, but still isolated. How do I expose a particular object instance from one language to the other? > After all I need to pass my Objective-C object to Python for evaluation and receive an answer from it in respose. > > A minimal sample function (as provided by the user at runtime) would look something like this: > > def shallRejectObject(object) > if object.foo(): > return True > return False > > Being totally new to PyObjC I'm thinking of some kind of reverse "objc.lookUpClass(…)" to allow me to instantiate my Python subclass from within Objective-C. Or how else would one approach this? Using Python from ObjC like this is suboptimal at the moment, mostly because I don't use PyObjC in that way. I'd define an stub class with the right interface in Objective-C with a subclass in Python that implements that interface. That way you can fetch the Python class using objc_lookUpClass (or the Foundation wrapper around that function), create an instance and then call the methods without getting compiler warnings. To expose instances you have to define an API to fetch those instances. Ronald > > Any hints? > > Thanks in advance, > Vincent > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Vincent <mai...@sa...> - 2012-05-20 20:25:28
|
Hi there, I'm new the whole PyObjC thing and have a simple document-bases app for which my goal is to all the user (personal project, so actually just me :P) to provide his/her (my) own filtering logic on a per-document basis. I basically have an NSSet of objects which need to be filtered based on a user-provided logic. As the logic should not be limited to rather primitive NSPredicates I'd like to provide a barebones in-app Python editor in which the user can define his/her logic. From what I've found on the web so far I know that one can subclass one's own Objective-C classes from inside Python using "objc.lookUpClass(…)". There is however still one question that remained unanswered: Being able to instantiate an Objective-C object from Python is neat, but still isolated. How do I expose a particular object instance from one language to the other? After all I need to pass my Objective-C object to Python for evaluation and receive an answer from it in respose. A minimal sample function (as provided by the user at runtime) would look something like this: def shallRejectObject(object) if object.foo(): return True return False Being totally new to PyObjC I'm thinking of some kind of reverse "objc.lookUpClass(…)" to allow me to instantiate my Python subclass from within Objective-C. Or how else would one approach this? Any hints? Thanks in advance, Vincent |
From: Nicholas C. <nic...@gm...> - 2012-04-16 16:44:44
|
On Mon, Apr 16, 2012 at 2:10 PM, <ron...@me...> wrote: > The autorelease pool does not have to be named pool. > > Cocoa has an internal protocol for finding the current autorelease pool, the > page below contains an explanation on how this could be implemented: > > > http://www.mikeash.com/pyblog/friday-qa-2011-09-02-lets-build-nsautoreleasepool.html > > That's not the real implementation though, the real implementation is closed > source and probably contains a number of tricks improve the speed. > Thanks for a really useful link. N. |
From: Nicholas C. <nic...@gm...> - 2012-04-16 13:00:06
|
> On Jan 2, 2012, at 5:01 PM, James Eagan wrote: > >> Hi Peter, >> >> You’re right, this is standard Objective-C memory management issue, but thankfully its easy to fix. Just create a new NSAutoreleasePool at the top of your loop and del it at the bottom. As an example, here’s the processing loop from one of my projects : >> >> for image in images: >> pool = NSAutoreleasePool.alloc().init() >> try: >> buffers.append( self.processImage_(image) ) >> finally: >> del pool >> Does the NSAutoreleasePool object need to be called "pool"? How do objects created 'know' that there is a pool available? Best wishes, Nicholas |
From: Joel N. <fra...@ya...> - 2012-04-11 06:08:34
|
Hi Virgil, Thank you for your work making it possible to embed Python in Objective-C with ObjP! I really appreciate your clear documentation and example code! It's very encouraging to me. Sincerely, Joel ________________________________ From: Virgil Dupras <hs...@ha...> To: Joel Norvell <fra...@ya...> Cc: "pyo...@li..." <pyo...@li...> Sent: Tuesday, April 10, 2012 6:15 AM Subject: Re: [Pyobjc-dev] Is there an Xcode Cocoa sample that calls Python? On 2012-04-10, at 3:43 AM, Joel Norvell wrote: > Hi PyObjC People, > > I'm interested in calling Python routines from within a Cocoa/ObjC program. > > Is there a sample Xcode project that does this? > > I did see Bill Bumgarner's "Calling Python from Objective-C" example and it's helpful. But I'm hoping for a Cocoa sample in an Xcode context to work from if one is available. > > I realize that this isn't purely a PyObjC question but I thought this list would be a good place to ask it on. > > Sincerely, > Joel Hi Joel, I wrote an article about that a couple of weeks ago. It might be a good starting point: http://www.hardcoded.net/articles/embedding-python-in-objc.htm There's even a link to guiskel in it. It's a sample project that does exactly that: https://bitbucket.org/hsoft/guiskel/overview Regards, Virgil Dupras |
From: Virgil D. <hs...@ha...> - 2012-04-10 13:32:06
|
On 2012-04-10, at 3:43 AM, Joel Norvell wrote: > Hi PyObjC People, > > I'm interested in calling Python routines from within a Cocoa/ObjC program. > > Is there a sample Xcode project that does this? > > I did see Bill Bumgarner's "Calling Python from Objective-C" example and it's helpful. But I'm hoping for a Cocoa sample in an Xcode context to work from if one is available. > > I realize that this isn't purely a PyObjC question but I thought this list would be a good place to ask it on. > > Sincerely, > Joel Hi Joel, I wrote an article about that a couple of weeks ago. It might be a good starting point: http://www.hardcoded.net/articles/embedding-python-in-objc.htm There's even a link to guiskel in it. It's a sample project that does exactly that: https://bitbucket.org/hsoft/guiskel/overview Regards, Virgil Dupras |
From: Joel N. <fra...@ya...> - 2012-04-10 07:44:04
|
Hi PyObjC People, I'm interested in calling Python routines from within a Cocoa/ObjC program. Is there a sample Xcode project that does this? I did see Bill Bumgarner's "Calling Python from Objective-C" example and it's helpful. But I'm hoping for a Cocoa sample in an Xcode context to work from if one is available. I realize that this isn't purely a PyObjC question but I thought this list would be a good place to ask it on. Sincerely, Joel |
From: James E. <jam...@te...> - 2012-01-02 22:30:32
|
Hi Peter, You’re right, this is standard Objective-C memory management issue, but thankfully its easy to fix. Just create a new NSAutoreleasePool at the top of your loop and del it at the bottom. As an example, here’s the processing loop from one of my projects : for image in images: pool = NSAutoreleasePool.alloc().init() try: buffers.append( self.processImage_(image) ) finally: del pool Alternatively, with the following category hack, you can use a with statement : # Add context manager methods to NSAutoreleasePool as a category hack class NSAutoreleasePool(objc.Category(NSAutoreleasePool)): def __enter__(self): return self def __exit__(self, ext, exv, extb): del self return False James Le 2 janv. 2012 à 21:14, Peter Bernheim a écrit : > I'm working on a script to convert each page of a large directory of pdfs to jpgs, using a version of this script: > http://files.macscripter.net/joy/files/pdflib.py > > I am walking through a directory in Python, and calling the below function on each file. It seems that there is no garbage collection being performed on any of the objects being created below, and my searches through the docs don't seem to show an explicit way of performing garbage collection on these rather large objects. How to ensure that the below code, if called thousands of times within a Python loop isn't going to consume the entire system's memory? > > > def pdf2jpgs(pdfpath, pages_dir, resolution=72): > """I am converting all pages of a PDF file to JPG images.""" > > pdfdata = NSData.dataWithContentsOfFile_(pdfpath) > pdfrep = NSPDFImageRep.imageRepWithData_(pdfdata) > pagecount = pdfrep.pageCount() > for i in range(0, pagecount): > pdfrep.setCurrentPage_(i) > pdfimage = NSImage.alloc().init() > pdfimage.addRepresentation_(pdfrep) > origsize = pdfimage.size() > width, height = origsize > pdfimage.setScalesWhenResized_(YES) > rf = resolution / 72.0 > pdfimage.setSize_((width*rf, height*rf)) > > tiffimg = pdfimage.TIFFRepresentation() > bmpimg = NSBitmapImageRep.imageRepWithData_(tiffimg) > data = bmpimg.representationUsingType_properties_(NSJPEGFileType, {NSImageCompressionFactor: 1.0}) > pagenum = i + 1 > jpgpath = "%s/pg%d.jpg" % (pages_dir, pagenum) > if not os.path.exists(jpgpath): > data.writeToFile_atomically_(jpgpath, False) > return '' > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev -- James R. Eagan Télécom–ParisTech www.telecom-paristech.fr/~eagan |
From: Peter B. <pe...@la...> - 2012-01-02 22:20:09
|
Thanks James, this works perfect! On Jan 2, 2012, at 5:01 PM, James Eagan wrote: > Hi Peter, > > You’re right, this is standard Objective-C memory management issue, but thankfully its easy to fix. Just create a new NSAutoreleasePool at the top of your loop and del it at the bottom. As an example, here’s the processing loop from one of my projects : > > for image in images: > pool = NSAutoreleasePool.alloc().init() > try: > buffers.append( self.processImage_(image) ) > finally: > del pool > > > Alternatively, with the following category hack, you can use a with statement : > > # Add context manager methods to NSAutoreleasePool as a category hack > class NSAutoreleasePool(objc.Category(NSAutoreleasePool)): > def __enter__(self): > return self > def __exit__(self, ext, exv, extb): > del self > return False > > James > > Le 2 janv. 2012 à 21:14, Peter Bernheim a écrit : > >> I'm working on a script to convert each page of a large directory of pdfs to jpgs, using a version of this script: >> http://files.macscripter.net/joy/files/pdflib.py >> >> I am walking through a directory in Python, and calling the below function on each file. It seems that there is no garbage collection being performed on any of the objects being created below, and my searches through the docs don't seem to show an explicit way of performing garbage collection on these rather large objects. How to ensure that the below code, if called thousands of times within a Python loop isn't going to consume the entire system's memory? >> >> >> def pdf2jpgs(pdfpath, pages_dir, resolution=72): >> """I am converting all pages of a PDF file to JPG images.""" >> >> pdfdata = NSData.dataWithContentsOfFile_(pdfpath) >> pdfrep = NSPDFImageRep.imageRepWithData_(pdfdata) >> pagecount = pdfrep.pageCount() >> for i in range(0, pagecount): >> pdfrep.setCurrentPage_(i) >> pdfimage = NSImage.alloc().init() >> pdfimage.addRepresentation_(pdfrep) >> origsize = pdfimage.size() >> width, height = origsize >> pdfimage.setScalesWhenResized_(YES) >> rf = resolution / 72.0 >> pdfimage.setSize_((width*rf, height*rf)) >> >> tiffimg = pdfimage.TIFFRepresentation() >> bmpimg = NSBitmapImageRep.imageRepWithData_(tiffimg) >> data = bmpimg.representationUsingType_properties_(NSJPEGFileType, {NSImageCompressionFactor: 1.0}) >> pagenum = i + 1 >> jpgpath = "%s/pg%d.jpg" % (pages_dir, pagenum) >> if not os.path.exists(jpgpath): >> data.writeToFile_atomically_(jpgpath, False) >> return '' >> ------------------------------------------------------------------------------ >> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex >> infrastructure or vast IT resources to deliver seamless, secure access to >> virtual desktops. With this all-in-one solution, easily deploy virtual >> desktops for less than the cost of PCs and save 60% on VDI infrastructure >> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > -- > James R. Eagan > Télécom–ParisTech > www.telecom-paristech.fr/~eagan > |
From: Peter B. <pe...@la...> - 2012-01-02 20:45:28
|
I'm working on a script to convert each page of a large directory of pdfs to jpgs, using a version of this script: http://files.macscripter.net/joy/files/pdflib.py I am walking through a directory in Python, and calling the below function on each file. It seems that there is no garbage collection being performed on any of the objects being created below, and my searches through the docs don't seem to show an explicit way of performing garbage collection on these rather large objects. How to ensure that the below code, if called thousands of times within a Python loop isn't going to consume the entire system's memory? def pdf2jpgs(pdfpath, pages_dir, resolution=72): """I am converting all pages of a PDF file to JPG images.""" pdfdata = NSData.dataWithContentsOfFile_(pdfpath) pdfrep = NSPDFImageRep.imageRepWithData_(pdfdata) pagecount = pdfrep.pageCount() for i in range(0, pagecount): pdfrep.setCurrentPage_(i) pdfimage = NSImage.alloc().init() pdfimage.addRepresentation_(pdfrep) origsize = pdfimage.size() width, height = origsize pdfimage.setScalesWhenResized_(YES) rf = resolution / 72.0 pdfimage.setSize_((width*rf, height*rf)) tiffimg = pdfimage.TIFFRepresentation() bmpimg = NSBitmapImageRep.imageRepWithData_(tiffimg) data = bmpimg.representationUsingType_properties_(NSJPEGFileType, {NSImageCompressionFactor: 1.0}) pagenum = i + 1 jpgpath = "%s/pg%d.jpg" % (pages_dir, pagenum) if not os.path.exists(jpgpath): data.writeToFile_atomically_(jpgpath, False) return '' |
From: Ronald O. <ron...@ma...> - 2011-12-29 06:42:31
|
On 27 Dec, 2011, at 22:08, Marc Van Olmen wrote: > hi, > > I looked around the web and more specific stack overflow: I was hoping if there is something I can do to have a better stack trace from pyobjc/python. <http://pypi.python.org/pypi/faulthandler/> might be helpful for this. I haven't used it myself yet, but as that module will be part of the stdlib in python 3.3 it should work well. This module would allow you to write code that saves a python stacktrace when a fatal error occurs, which users could then mail to you. Ronald > > For example my end users send me this, after a hard crash. > > 0 libobjc.A.dylib 0x99b51c22 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 350 > 1 com.apple.CoreFoundation 0x97b2c515 _CFAutoreleasePoolPop + 53 > 2 com.apple.Foundation 0x96316b87 -[NSAutoreleasePool release] + 131 > 3 com.apple.CoreFoundation 0x97b01749 CFRelease + 169 > 4 _objc.so 0x04019c21 object_dealloc + 257 > 5 org.python.python 0x01c6e2cf subtype_dealloc + 575 > 6 org.python.python 0x01c3a041 frame_dealloc + 385 > 7 org.python.python 0x01ced87c tb_dealloc + 156 > 8 org.python.python 0x01ced88c tb_dealloc + 172 > 9 org.python.python 0x01c52179 PyDict_DelItem + 249 > 10 org.python.python 0x01c52251 PyDict_DelItemString + 49 > 11 org.python.python 0x01cb940a PyEval_EvalFrameEx + 4810 > 12 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 13 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 14 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 15 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 16 org.python.python 0x01cbee9d PyEval_EvalCodeEx + 2109 > 17 org.python.python 0x01c3ba36 function_call + 166 > 18 org.python.python 0x01c0a315 PyObject_Call + 85 > 19 org.python.python 0x01c1c8e6 instancemethod_call + 422 > 20 org.python.python 0x01c0a315 PyObject_Call + 85 > 21 org.python.python 0x01cb717e PyEval_CallObjectWithKeywords + 78 > 22 org.python.python 0x01cf89d6 t_bootstrap + 70 > 23 libsystem_c.dylib 0x957c2ed9 _pthread_start + 335 > 24 libsystem_c.dylib 0x957c66de thread_start + 34 > > Would be nice to know which method and object was called at > > PyEval_EvalFrameEx + 21862 > > for example. > > Marc > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev_______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
From: Marc V. O. <mar...@gm...> - 2011-12-28 15:47:30
|
Thanks to both of you for your thoughtful answers! I just looked at the source code of: http://pypi.python.org/pypi/faulthandler/ This looks very interesting, it doesn't seem to have much overhead, I could easily add this to my shipping app. This could be a very helpful tool. Thanks again. marc On Wed, Dec 28, 2011 at 6:34 AM, Ronald Oussoren <ron...@ma...>wrote: > You cannot extract the python stack trace from a Apple crash log, but > could save one yourself using the faulthandler package < > http://pypi.python.org/pypi/faulthandler/>. > > I have a slightly longer message in my mail.app outgoing folder, that will > get send once I have full Internet connectivity again (this mail is send > through webmail). > > Ronald > > On Dec 28, 2011, at 09:09 AM, Ken Thomases <ke...@co...> wrote: > > On Dec 27, 2011, at 3:08 PM, Marc Van Olmen wrote: > > > I looked around the web and more specific stack overflow: I was hoping > if there is something I can do to have a better stack trace from > pyobjc/python. > > > > For example my end users send me this, after a hard crash. > > > > 0 libobjc.A.dylib 0x99b51c22 (anonymous > namespace)::AutoreleasePoolPage::pop(void*) + 350 > > 1 com.apple.CoreFoundation 0x97b2c515 _CFAutoreleasePoolPop + 53 > > 2 com.apple.Foundation 0x96316b87 -[NSAutoreleasePool release] + 131 > > 3 com.apple.CoreFoundation 0x97b01749 CFRelease + 169 > > 4 _objc.so 0x04019c21 object_dealloc + 257 > > 5 org.python.python 0x01c6e2cf subtype_dealloc + 575 > > 6 org.python.python 0x01c3a041 frame_dealloc + 385 > > 7 org.python.python 0x01ced87c tb_dealloc + 156 > > 8 org.python.python 0x01ced88c tb_dealloc + 172 > > 9 org.python.python 0x01c52179 PyDict_DelItem + 249 > > 10 org.python.python 0x01c52251 PyDict_DelItemString + 49 > > 11 org.python.python 0x01cb940a PyEval_EvalFrameEx + 4810 > > 12 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > > 13 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > > 14 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > > 15 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > > 16 org.python.python 0x01cbee9d PyEval_EvalCodeEx + 2109 > > 17 org.python.python 0x01c3ba36 function_call + 166 > > 18 org.python.python 0x01c0a315 PyObject_Call + 85 > > 19 org.python.python 0x01c1c8e6 instancemethod_call + 422 > > 20 org.python.python 0x01c0a315 PyObject_Call + 85 > > 21 org.python.python 0x01cb717e PyEval_CallObjectWithKeywords + 78 > > 22 org.python.python 0x01cf89d6 t_bootstrap + 70 > > 23 libsystem_c.dylib 0x957c2ed9 _pthread_start + 335 > > 24 libsystem_c.dylib 0x957c66de thread_start + 34 > > > > > > Would be nice to know which method and object was called at > > > > PyEval_EvalFrameEx + 21862 > > > > for example. > > I assume you know that "PyEval_EvalFrameEx + 21862" doesn't correspond to > any particular Python code. Since Python is running as an interpreter, the > Python code is purely data and doesn't correspond to any machine > instructions. Therefore, the stack trace doesn't "see" it. It's only seeing > the Python interpreter's functions. > > So, you're asking for the crash reporter to look into the data being used > by a function, not just translating the function's address to a symbol. > Certainly, there's no way to coax the crash reporter to do that. Likewise, > there's no way to deduce the Python code being executed just by analyzing a > crash report. > > Since the crash appears to be due to an over-release, you can try to get > more information about the specific object using the "zombies" facilities > of the frameworks. If the issue is reproducible, you can ask your users to > run your app with certain environment variables set, such as: > > CFZombieLevel=19 NSZombieEnabled=YES > /Applications/YourApp.app/Contents/MacOS/YourApp > > (I'm not actually certain that the "CFZombieLevel=19" is desirable. You > might have them try with and without, if they're willing.) > > That should at least cause a better diagnostic message to be printed to > the console log at the time of the crash. I believe that messaging a zombie > triggers a SIGTRAP these days instead of raising an exception. The latter > would have been nice in that it might have been translated into a Python > exception and provoked Python into dumping a backtrace. Instead, the > SIGTRAP will just crash your app in a slightly different way than the > above. However, you may be able to translate the SIGTRAP into a Python > exception by setting a Python signal handler for SIGTRAP. That would get > you a better backtrace from zombies. > > By the way, you've excerpted a crash report. You may have left out some > important information about the specific nature of the crash. Also, if you > haven't already, you should ask your users if anything was written to the > console log at the same time as the crash. > > Good luck, > Ken > > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |
From: Ronald O. <ron...@ma...> - 2011-12-28 11:34:51
|
You cannot extract the python stack trace from a Apple crash log, but could save one yourself using the faulthandler package <http://pypi.python.org/pypi/faulthandler/>. I have a slightly longer message in my mail.app outgoing folder, that will get send once I have full Internet connectivity again (this mail is send through webmail). Ronald On Dec 28, 2011, at 09:09 AM, Ken Thomases <ke...@co...> wrote: On Dec 27, 2011, at 3:08 PM, Marc Van Olmen wrote: > I looked around the web and more specific stack overflow: I was hoping if there is something I can do to have a better stack trace from pyobjc/python. > > For example my end users send me this, after a hard crash. > > 0 libobjc.A.dylib 0x99b51c22 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 350 > 1 com.apple.CoreFoundation 0x97b2c515 _CFAutoreleasePoolPop + 53 > 2 com.apple.Foundation 0x96316b87 -[NSAutoreleasePool release] + 131 > 3 com.apple.CoreFoundation 0x97b01749 CFRelease + 169 > 4 _objc.so 0x04019c21 object_dealloc + 257 > 5 org.python.python 0x01c6e2cf subtype_dealloc + 575 > 6 org.python.python 0x01c3a041 frame_dealloc + 385 > 7 org.python.python 0x01ced87c tb_dealloc + 156 > 8 org.python.python 0x01ced88c tb_dealloc + 172 > 9 org.python.python 0x01c52179 PyDict_DelItem + 249 > 10 org.python.python 0x01c52251 PyDict_DelItemString + 49 > 11 org.python.python 0x01cb940a PyEval_EvalFrameEx + 4810 > 12 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 13 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 14 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 15 org.python.python 0x01cbd6a6 PyEval_EvalFrameEx + 21862 > 16 org.python.python 0x01cbee9d PyEval_EvalCodeEx + 2109 > 17 org.python.python 0x01c3ba36 function_call + 166 > 18 org.python.python 0x01c0a315 PyObject_Call + 85 > 19 org.python.python 0x01c1c8e6 instancemethod_call + 422 > 20 org.python.python 0x01c0a315 PyObject_Call + 85 > 21 org.python.python 0x01cb717e PyEval_CallObjectWithKeywords + 78 > 22 org.python.python 0x01cf89d6 t_bootstrap + 70 > 23 libsystem_c.dylib 0x957c2ed9 _pthread_start + 335 > 24 libsystem_c.dylib 0x957c66de thread_start + 34 > > > Would be nice to know which method and object was called at > > PyEval_EvalFrameEx + 21862 > > for example. I assume you know that "PyEval_EvalFrameEx + 21862" doesn't correspond to any particular Python code. Since Python is running as an interpreter, the Python code is purely data and doesn't correspond to any machine instructions. Therefore, the stack trace doesn't "see" it. It's only seeing the Python interpreter's functions. So, you're asking for the crash reporter to look into the data being used by a function, not just translating the function's address to a symbol. Certainly, there's no way to coax the crash reporter to do that. Likewise, there's no way to deduce the Python code being executed just by analyzing a crash report. Since the crash appears to be due to an over-release, you can try to get more information about the specific object using the "zombies" facilities of the frameworks. If the issue is reproducible, you can ask your users to run your app with certain environment variables set, such as: CFZombieLevel=19 NSZombieEnabled=YES /Applications/YourApp.app/Contents/MacOS/YourApp (I'm not actually certain that the "CFZombieLevel=19" is desirable. You might have them try with and without, if they're willing.) That should at least cause a better diagnostic message to be printed to the console log at the time of the crash. I believe that messaging a zombie triggers a SIGTRAP these days instead of raising an exception. The latter would have been nice in that it might have been translated into a Python exception and provoked Python into dumping a backtrace. Instead, the SIGTRAP will just crash your app in a slightly different way than the above. However, you may be able to translate the SIGTRAP into a Python exception by setting a Python signal handler for SIGTRAP. That would get you a better backtrace from zombies. By the way, you've excerpted a crash report. You may have left out some important information about the specific nature of the crash. Also, if you haven't already, you should ask your users if anything was written to the console log at the same time as the crash. Good luck, Ken ------------------------------------------------------------------------------ Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev _______________________________________________ Pyobjc-dev mailing list Pyo...@li... https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |