[Zope] array module and pickleing ques

Charlie Reiman creiman@kefta.com
Wed, 10 Jul 2002 17:50:22 -0700


Two suggestions come to mind but I doubt either will help.

1) Change your last line to:
  # Clean up.
  y=x.tostring()
  x=None
  return y

2) Rename 'x' to something longer. If you have a module variable named x,
the array will stick around after returning. It still shouldn't be
serialized, as it isn't part of your object, but I don't really have any
other suggestions.

Neither of these should matter but it's worth a shot.

Also, double check your indentation on the for loop. Make sure that return
is not inside the loop. That shouldn't matter either though...

Oh, wait, one more suggestion. Don't write this as a method. Stick it in a
python script or an external method. Your class should not even import array
that way.

> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Aseem
> Mohanty
> Sent: Wednesday, July 10, 2002 5:26 AM
> Cc: zope@zope.org
> Subject: Re: [Zope] array module and pickleing ques
>
>
> That seems to be the answer. However I tried Charlie's suggestions and
> made the data members as lists (not strings as he suggested, seemed to
> work equally well and I didnt have to switch back and forth between
> functions calls) instead of arrrays and only instantiated arrays where I
> needed to use them (only inside of functions) as local variables.
>
> Well it doesnt work. Everytime that function (that has an array
> declaration inside) is called I get another UnpickleableError.
> I am at my wit's end... how do I get around it or force it through...
>
> any help would greatly appreciated.
>
> one function that raises that error:
>
> def _reverse_hex(self,s):
>         x=array.array('c',s) ## causes the error .... no problems if I
> remove it
>         for i in range(0,len(s),4):
>             a=x[i]
>             b=x[i+1]
>             c=x[i+2]
>             d=x[i+3]
>
>             x[i]=c
>             x[i+1]=d
>             x[i+2]=a
>             x[i+3]=b
>         return x.tostring()
>
> TIA
> AM
>
> Dieter Maurer wrote:
>
> >Aseem Mohanty writes:
> > > why does a call to array.array() cause an unpickleable error??
> >Probably, because it is not a standard Python class but implemented
> >in "C" and the author did not provide "setstate/getstate" methods.
> >
> >Pickling means serializing. Apparently, the pickle modules does
> >not know how to serialize "array"s.
> >
> >
> >Dieter
> >
> >.
> >
>
> --
> ==================================================================
>  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 )
>