I am actually porting a previously implemented encryption algorithm to be used in Zope and need to be able to differentiate between byte arrays and word arrays. I will try your suggestion. Thanks AM Charlie Reiman wrote:
Testing it from the python interpreter, it appears you are correct. array.array is not pickleable. As a wild guess, array is probably a C class and they just neglected to add that support. Since you don't say why your values must be two bytes, I can't offer any real work arounds.
But as a guess, you might be able to work something with array.array's to/fromstring stuff, and keep the array.array in a volatile attribute.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Aseem Mohanty Sent: Tuesday, July 09, 2002 10:55 PM Cc: zope@zope.org Subject: Re: [Zope] array module and pickleing ques
some more info: the error:
Error Type: UnpickleableError Error Value: Cannot pickle objects
------------------------------------------------------------------------
Troubleshooting Suggestions
* The URL may be incorrect. * The parameters passed to this resource may be incorrect. * A resource that this resource relies on may be encountering an error.
For more detailed information about the error, please refer to the HTML source for this page.
If the error persists please contact the site maintainer. Thank you for your patience.
Traceback (innermost last): File F:\KANDIN~1\lib\python\ZPublisher\Publish.py , line 150, in publish_module File F:\KANDIN~1\lib\python\ZPublisher\Publish.py , line 114, in publish File F:\KANDIN~1\lib\python\Zope\__init__.py , line 158, in zpublisher_exception_hook File F:\KANDIN~1\lib\python\ZPublisher\Publish.py , line 102, in publish File F:\KANDIN~1\lib\python\Zope\__init__.py , line 172, in commit File f:\kandinsky\lib\python\Products\TransactionAgents\__init__.py , line 54, in new_commit File F:\KANDIN~1\lib\python\ZODB\Transaction.py , line 233, in commit File F:\KANDIN~1\lib\python\ZODB\Connection.py , line 345, in commit (Info: (('Products.RC2.RC2', 'RC2'), '\x00\x00\x00\x00\x00\x00h\xe1', '')) UnpickleableError: (see above)
I also tried the following in the python console:
Python 2.1.2 (#31, Jan 15 2002, 17:28:11) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information.
import pickle, array, os f= open('test','w') x = array.array('H') pickle.dump(x,f) Traceback (most recent call last): File "<stdin>", line 1, in ? File "F:\KANDIN~1\bin\lib\pickle.py" , line 939, in dump Pickler(file, bin).dump(object) File "F:\KANDIN~1\bin\lib\pickle.py" , line 109, in dump self.save(object) File "F:\KANDIN~1\bin\lib\pickle.py" , line 171, in save raise PicklingError, \ pickle.PicklingError: can't pickle 'array' object: array('H')
The problem is that I NEED that array sizes to be 1 or 2 bytes and I dont know how to get around this problem without arrays.
Any help would be greatly appreciated.
TIA AM
Aseem Mohanty wrote:
why does a call to array.array() cause an unpickleable error??
the pickle docs on the python site dont mention anything about arrays, nor do the array docs mention about pickling.
i have a feeling that it might be because of the fact that arrays are dynamic data structures and thus the pickler doesnt really know about its limits (of course I could be totally and miserably wrong) i couldnt find anything in the docs to support my 'feeling' and the source is kind of above my current level of expertise in python
any help would be appreciated or i am doomed to a major rewrite....
the source in my product that causes the error :
self.K=array.array('H') self.L=array.array('B') self.R=array.array('H')
TIA AM
-- ================================================================== Aseem Mohanty Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231 ============================================================ ====== "I saw `cout' being shifted "Hello world" times to the left and stopped right there!!" -- Steve Gonedes ==================================================================
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- ================================================================== Aseem Mohanty Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231 ================================================================== "I saw `cout' being shifted "Hello world" times to the left and stopped right there!!" -- Steve Gonedes ==================================================================