Re: [Pyobjc-dev] In and out of NSData
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-01-08 06:41:31
|
On Tuesday, Jan 7, 2003, at 16:30 Europe/Amsterdam, Bob Ippolito wrote: > I updated to latest CVS.. it seems that you may now initialize > NSData/NSMutableData with a python string or an array, but it breaks > for big ones. > > >>> from Foundation import * > >>> import array > >>> bytes = array.array('b', 'abcdef') > >>> NSData.alloc().initWithBytes_length_(bytes, len(bytes)) > <a07e> > >>> NSMutableData.alloc().initWithBytes_length_(bytes, len(bytes)) > <a07eda48 00000001 00000000 00000054 007db1e0 00000000 00000000 > 00000001 76304034 3a385e76 31324931 36000001 76304034 3a384931 > 32000000 00010002 76> > >>> bytes = array.array('b', 'abcdef' * 1000) > >>> NSData.alloc().initWithBytes_length_(bytes, len(bytes)) > Segmentation fault > You can work around this by using 'NSData.dataWithBytes_length_' for now. There seems to be a problem with reference counts (based on a quick glance at a traceback in gdb), the segfault is caused by the release of 'self' when deallocating the bound method 'initWithBytes_length_', and this self doesn't have a valid 'isa' pointer. Ronald |